zOs/REXX.O13/EXTAB
/* rexx *************************************************************
*********************************************************************/
parse arg fun
say 'tabEins fun'
if fun = '' then do
call adrIsp 'tbcreate tb1 names(date time info) nowrite'
call fillRow 'Eins'
call adrIsp 'tbAdd tb1 save(ex1 ex2)'
call sayRow 'add'
call fillRow 'reset'
call sayRow 'reset'
call adrIsp 'tbGet tb1 savename(extvars)'
call sayRow 'get('extVars')'
call adrTso "call 'CMN.DIV.P0.A18A.#000004.LLB(WKISP)'",
"'rec und Weiter ?' asis"
call adrTso "call 'CMN.DIV.P0.A18A.#000004.LLB(WKISP)'",
"'zweiter versuch' asis"
call adrIsp 'tbend tb1'
end
else do
call sayRow 'entry'
call adrIsp 'tbAdd tb1 save(ex1 ex2)'
call adrIsp 'tbGet tb1 savename(extvars)'
call sayRow 'e get('extVars')'
end
exit
sayRow:
parse arg tit
say tit 'date' date 'time' time 'info' info
say ' ex1' ex1 'ex2' ex2 'ot1' ot1
return
fillRow:
parse arg rid
date = date(s)
time = time(l)
info = 'info'rid
ex1 = 'ex1='rid
ex2 = 'ex2='rid
ot1 = 'ot1='rid
return
/*********************************************************************/
rz = sysvar('SYSNODE')
dsnPref = 'OMS.DIV.P0.STAT.'rz'.ASC'
say 'start POV Monats Statistik Kollektor'
say ' Version 0.2 A540769.ISPF.REXX(POVMONKO)'
say ' in RZ' rz 'dsnPrefix' dsnPref
call allocateDsn date('S'), dsnPref
call adrTso "call *(ts5240) "
call freeRename (adrTsoRc = 0)
if rz ^= 'RZ1' then
call transferDsn /* transfer new datasets to rz1 */
return /* main */
/*********************************************************************
main code END
*********************************************************************/
allocateDsn:
/*********************************************************************
generate Datasetnames
allocate month input and output DD's for current and previous month
*********************************************************************/
parse arg dt, pref
ym = left(dt, 6)
sv = right(dt, 6)
say dt '=>' ym sv
do i=1 to 9 /* compute fileNames */
yymm.i = substr(ym, 3, 4)
dsn.i = pref'.Y'left(yymm.i, 2)'M'right(yymm.i, 2)
say i yymm.i dsn.i
if right(ym, 2) > 1 then
ym = left(ym, 4)translate(format(right(ym, 2) - 1, 2),
, '0' , ' ')
else
ym = (left(ym, 4) - 1)'12'
end
like = ''
do i=1 to 2 /* allocate mon in */
if sysDsn("'"dsn.i"'") = 'OK' then do
if like = '' then
like = "'"dsn.i"'"
call adrTso "alloc dd(MoIn"yymm.i") shr reuse",
"dsn('"dsn.i"')"
end
else
call adrTso "alloc dd(MoIn"yymm.i") reuse dummy"
end
do while like='' /* look for a like dataset */
if sysDsn("'"dsn.i"'") = 'OK' then
like = "'"dsn.i"'"
else if i > 5 then
call err 'no existing dataset found from ' dsn.1 'to' dsn.i
i = i + 1
end
do i=1 to 2 /* allocate mon out */
dsn = "'"dsn.i".NEW'"
if sysDsn(dsn) = 'OK' then
call adrTso "delete" dsn
call adrTso "alloc dd(MoOu"yymm.i") new catalog reuse",
" dsn("dsn") like("like") MGMTCLAS(S005N000)"
end
return; /* allocateDsn */
freeRename:
/*********************************************************************
free and rename the month Datasets depending on result
*********************************************************************/
parse arg ok
do i=1 to 2
call adrTso "free dd(MoIn"yymm.i")"
ff = listDsi('MoOu'yymm.i file)
if ff ^= 0 then
call err 'rc' ff 'from listDsi(MoOu'yymm.i 'file)',
'reason' sysReason
say 'listDsi(moOu'yymm.i') use' sysUsed 'alloc'sysAlloc sysUnits
if sysUsed = 0 then do
call adrTso "free dd(MoOu"yymm.i") delete"
end
else do
call adrTso "free dd(MoOu"yymm.i") catalog"
if ok then do
if sysDsn("'"dsn.i"'") = 'OK' then do
if sysDsn("'"dsn.i".SV"sv"'") = 'OK' then
call adrTso "delete '"dsn.i"'"
else
call adrTso "rename '"dsn.i"' '"dsn.i".SV"sv"'"
end
call adrTso "rename '"dsn.i".NEW' '"dsn.i"'"
transfer.i = 1
end
else do
if sysDsn("'"dsn.i".ER"sv"'") = 'OK' then
call adrTso "delete '"dsn.i".ER"sv"'"
call adrTso "rename '"dsn.i".NEW' '"dsn.i".ER"sv"'"
end
end
end
return /* freeRename */
transferDsn:
/*********************************************************************
transfer the newly created/modified month files to RZ1
*********************************************************************/
do i=1 to 2
say 'transfer.'i transfer.i
if transfer.i = 1 then
call connectDirect dsn.i, 'RZ1', dsn.i'.TRANSFER'
end
return /* end transfer */
connectDirect: procedure
/*******************************************************************
send the file frDsn from the current not
to the node toNode as toDsn
using connect direct
********************************************************************/
parse upper arg frDsn, toNode, toDsn
say 'sending' frDsn 'to' toNode toDsn 'with connect direct'
call adrTso "alloc shr dd(sysut1) reuse dsn('"frDsn"')"
call adrTso "alloc new delete dd(DDIN) dsn("tempPref()".ddin)" ,
"recfm(f,b) lrecl(80)"
t.1 ="DSN='"toDsn"'"
t.2 ="DEST='"toNode"'"
t.3 ="DSNCOPY='YES'"
call adrTso 'EXECIO 3 DISKW DDIN (STEM t. FINIS)'
if 0 then do
call adrTso 'EXECIO * DISKr DDIN (STEM r. FINIS)'
say 'read' r.0
do i=1 to r.0
say i r.i
end
end
call adrTso "call *(OS2900)"
/* call adrTso 'free dd(sysut1)' an unknown ghost free it already */
call adrTso 'free dd(ddin) delete'
say 'end connectDirect'
return /* end connectDirect */
tempPref: procedure
l = time(l);
d = 'tempFile.t'left(l,2)substr(l,4,2)substr(l,7,2)'.m'right(l,6)
return d /* end tempPref */
adrTso:
parse arg tsoCmd
/* say 'adrTso' tsoCmd */
address tso tsoCmd
adrTsoRc = rc
say 'adrTso rc' adrTsoRc 'for' tsoCmd
return
adrIsp:
parse arg ispCmd
/* say 'adrTso' tsoCmd */
address ispExec ispCmd
adrIspRc = rc
say 'adrIsp rc' adrIspRc 'for' ispCmd
return
err:
parse arg errMsg
say 'fatal error:' errMsg
exit 12