zOs/REXX.O08/CONNDIR
/* rexx *************************************************************
POV Monats Statistik Kollektor
Ueberblick
Alloziert die Monats Files
lässt TS5240 laufen (Die Tagesfile müssen im JCL alloziert werden)
falls TS5240 einen Returncode 0 zurückgibt
wird das alte Monatsfile gesavt und durch das neue ersetzt
sonst
wird das neue Monatsfile auf .....ER<Datum> umbenannt
die (fehlerfreien) neuen Monatsfiles werden auf RZ1 transferiert
Parameter: 4 space getrennte Worte ('*' oder '' für Default)
1. Wort: MonatVon (yyMM), default letzter Monat
2. Wort: MonatBis (yyMM), default aktueller Monat
3. Wort: dsnPrefix für MonatsFiles, default 'OMS.DIV.P0.STAT.'rz
4. Wort: 'SV': erstelle jeden Tag einen Save vom InputMonatsfile
mit suffix .SVjjmmtt, kein Save falls 4. Wort leer
FileNamen
mit jj zweistelliges Jahr, mm Monat , tt Tag
zzz RZ Name (RZ1, RZ2, RZ4)
OMS.DIV.P0.STAT.zzz.YjjMoo (altes) Monatsfile
OMS.DIV.P0.STAT.zzz.YjjMoo.NEW (neues) Monatsfile
OMS.DIV.P0.STAT.zzz.YjjMoo.SVjjoott Save des alten Monatsfile
OMS.DIV.P0.STAT.zzz.YjjMoo.ERjjoott Fehlerhaftes neues Monatsfile
History
12.11.04 Walter Keller, KPCO4 neu
10.12.04 Walter Keller, Parameter eingebaut
*********************************************************************/
DSN = 'A540769.TMP.LISTDEF'
call connectDirect dsn, 'RZ2', dsn
exit
/*********************************************************************
main code BEGIN
*********************************************************************/
parse arg monatVon monatBis dsnPref svSuf
say 'start POV Monats Statistik Kollektor'
say ' Version 0.2 OMS.DIV.P0.CLIST(POVMONKO)'
rz = sysvar('SYSNODE')
if dsnPref = '' | dsnPref = '*' then
dsnPref = 'OMS.DIV.P0.STAT.'rz
say ' in RZ' rz 'dsnPrefix' dsnPref
today = date('s')
if monatVon <> '' & monatVon <> '*' then
monatVon = checkMonat(monatVon)
else if substr(today, 5, 2) > '01' then
monatVon = substr(today, 3, 4) - 1
else
monatVon = substr(today, 3, 4) - 89
if monatBis = '' | monatBis = '*' then
monatBis = substr(today, 3, 4)
else
monatBis = checkMonat(monatBis)
say ' Monate' translate(format(monatVon, 4), '0' , ' ') ,
'-' translate(format(monatBis, 4), '0' , ' ')
erSuf = 'ER' || right(today, 6)
if svSuf = '' | svSuf = '*' then do
svSuf = ''
say ' ohne save errorSuffix' erSuf
end
else do
if length(svSuf) > 2 then
svSuf = left(svSuf, 2)
svSuf = svSuf || right(today, 6)
say ' save mit suffix' svSuf 'errorSuffix' erSuf
end
call allocateDsn
call adrTso "call *(ts5240) 't'"
call freeRename (adrTsoRc = 0)
exit
if rz ^= 'RZ1' then
call transferDsn /* transfer new datasets to rz1 */
return /* main */
/*********************************************************************
main code END
*********************************************************************/
checkMonat: procedure
parse arg ym
if verify(ym, '0123456789') <> 0 then
call err('monat nicht numerisch:' ym)
else if ym > 9999 then
call err('monat hat mehr als 4 Stellen (yymm):' ym)
if ym // 100 < 1 | ym // 100 > 12 then
call err('monat nicht zischen 1 und 12:' ym)
return ym /* checkMonat */
allocateDsn:
/*********************************************************************
generate Datasetnames
allocate month input and output DD's for current and previous month
*********************************************************************/
ym = monatVon
monatBis = translate(format(monatBis, 4), '0', ' ')
do i=1 by 1 /* compute fileNames */
yymm.i = translate(format(ym // 10000, 4), '0', ' ')
dsn.i = dsnPref'.Y'left(yymm.i, 2)'M'right(yymm.i, 2)
if yymm.i = monatBis then
leave
if ym // 100 >= 12 then
ym = ym + 89
else
ym = ym + 1
end
hix = i
say hix 'monate' yymm.1 '-' yymm.hix 'save' svSuf 'pref' dsnPref
like = ''
do i=1 to hix /* 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
if like = '' then
call err 'no existing dataset found from ' dsn.1 'to' dsn.hix
do i=1 to hix /* 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 hix
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 svSuf = '' then
call adrTso "delete '"dsn.i"'"
else if sysDsn("'"dsn.i"."svSuf"'") = 'OK' then
call adrTso "delete '"dsn.i"'"
else
call adrTso "rename '"dsn.i"' '"dsn.i"."svSuf"'"
end
call adrTso "rename '"dsn.i".NEW' '"dsn.i"'"
transfer.i = 1
end
else do
if sysDsn("'"dsn.i"."erSuf"'") = 'OK' then
call adrTso "delete '"dsn.i"."erSuf"'"
call adrTso "rename '"dsn.i".NEW' '"dsn.i"."erSuf"'"
end
end
end
return /* freeRename */
transferDsn:
/*********************************************************************
transfer the newly created/modified month files to RZ1
*********************************************************************/
do i=1 to hix
say 'transfer.'i transfer.i
if transfer.i = 1 then
call connectDirect dsn.i, 'RZ1', dsn.i
end
return /* end transfer */
connectDirect: procedure
/*******************************************************************
send the file frDsn from the current not
to the node toNode as toDsn
using connect direct
********************************************************************/
trace ?R
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 ="MGMTCLAS='S005N000'"
t.4 ="DSNCOPY='YES'"
call adrTso 'EXECIO 4 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)' a ghost freed it already */
call adrTso 'free dd(ddin) delete'
/* os2900 does not free it dd's, so we do it
otherwise the second run will fail... */
call adrTso 'free dd(ddPrint)'
call adrTso 'free dd(work01)'
call adrTso 'free dd(cmdout)'
call adrTso 'free dd(dmprint)'
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
err:
parse arg errMsg
say 'fatal error:' errMsg
exit 12