Cat/Dir REORG JCLs Part 4 - CATLIST

Michael Ebert

Cat/Dir REORG JCLs Part 4 - CATLIST
Dr. Michael Ebert
DB2 Database Administrator
aMaDEUS Data Processing
Erding / Munich, Germany
Tel. ++49 -8122-433962
Fax ++49-8122-433260


/*---------------------REXX-----------------------------------------*/
/*------------------------------------------------------------------*/
parse upper arg ssid

ofile="OBO025.CATLIST.TXT"

/* because DSNDB01 is not in the Catalog, add it explicitly: */
b.1="DSNDB01 DBD01 "
b.2="DSNDB01 SCT02 DSNSCT02"
b.3="DSNDB01 SPT01 DSNSPT01"
b.4="DSNDB01 SPT01 DSNSPT02"
b.5="DSNDB01 SYSLGRNX DSNLLX01"
b.6="DSNDB01 SYSLGRNX DSNLLX02"
b.7="DSNDB01 SYSUTILX DSNLUX01"
b.8="DSNDB01 SYSUTILX DSNLUX02"
k=8

address TSO "PIPE SQL SSID" ssid ,
"SELECT A.DBNAME, A.TSNAME, B.INDEXSPACE",
" FROM SYSIBM.SYSTABLES A," ,
" SYSIBM.SYSINDEXES B" ,
" WHERE A.CREATOR=B.TBCREATOR" ,
" AND A.NAME=B.TBNAME" ,
" AND A.TYPE='T'" ,
" AND B.DBNAME='DSNDB06'" ,
" ORDER BY 1, 2, 3" ,
"|stem rec."

x='0000'x /* Separator string */
do i=1 to rec.0
parse var rec.i (x) dbname (x) tsname (x) ixname
k=k+1
b.k=dbname tsname ixname
end

a.=""; a.0=0; dbold="???"; tsold="???"
sum.=0
do i=1 to k
parse var b.i dbname tsname ixname
dbname=strip(dbname); tsname=strip(tsname); ixname=strip(ixname)
if dbname\=dbold | tsname\=tsold then do;
dbold=dbname; tsold=tsname
a.0=a.0+1
x=vsaminfo(ssid".DSNDBD."dbname"."tsname".I0001.A001")
x=format_list()
end
if ixname\="" then do;
x=vsaminfo(ssid".DSNDBD."dbname"."ixname".I0001.A001")
x=format_list()
end
end
j=a.0+2; volume="A"
a.j="SUM(ucyls) for Volume A:" right(sum.volume,6)
j=j+1; volume="B"
a.j="SUM(ucyls) for Volume B:" right(sum.volume,6)
a.0=j

"alloc da('"ofile"') f(IO) shr reu"
"execio "a.0" diskw IO (stem a. finis"
"free f(IO)"

address ispexec "EDIT DATASET('"ofile"')"
exit


format_list: procedure expose a. vsam. sum.
j=a.0
do i=1 to vsam.0
atrks=(vsam.#ASPACE.i-1)%48+1
acyls=(vsam.#ASPACE.i-1)%720+1
utrks=(vsam.#USPACE.i-1)%48+1
ucyls=(vsam.#USPACE.i-1)%720+1
parse var vsam.#DS.i x "." x "." dbname "." tsname "." x ".A" dsnum

volume="A"; if left(tsname, 3)="DSN" then volume="B" /* Index */
if tsname="SPT01" then volume="B"
if wordpos(tsname, "DSNSPT01 DSNSPT02 DSNKSX01")>0 then volume="A"

j=j+1
a.j=volume left(tsname,8) right(atrks,8) right(utrks,8) ,
right(acyls,6) right(ucyls,6) vsam.#UNIT.i right(vsam.#XT.i,3)
sum.volume=sum.volume+ucyls
end /* do i=1 to vsam.0 */
a.0=j
return j /* format_list */


/* All space quantities are in KB!! */
vsaminfo: procedure expose vsam.
arg prefix

vsam.=""
x=time("R")
x=outtrap(a.)
address tso "listc en('"prefix"') alloc"
x=outtrap("OFF")
/* if only 4 rows, it means "Entry not found..." - try LISTC LVL: */
if a.0=4 then do;
x=outtrap(a.)
address tso "listc lvl('"prefix"') alloc"
x=outtrap("OFF")
end
x=time("R")
/*say a.0 "Rows, LISTC Time=" x "seconds."
*/if a.0=4 then a.0=0 /* DS does not exist */
i=1; j=0
do while substr(a.i, 1, 8)="DATA ---"
j=j+1
kb_per_unit=1
vsam.#DS.j=strip(substr(a.i, 16))
i=i+7; if substr(a.i, 8, 10)^="SPACE-TYPE" then trace '?r'
h=strip(substr(a.i, 22, 10), "L", "-")
if h="CYLINDER" then do
vsam.#UNIT.j="C"; kb_per_unit=720
end; else if h="TRACK" then do
vsam.#UNIT.j="T"; kb_per_unit=48
end; else do
say "Cannot handle Space-Type" h "for DS" vsam.#DS.j
trace '?r'
end
if substr(a.i, 37, 10)^="HI-A-RBA--" then trace '?r'
vsam.#ASPACE.j=(strip(substr(a.i, 49, 12), "L", "-")+1023)%1024
i=i+1; if substr(a.i, 8, 10)^="SPACE-PRI-" then trace '?r'
vsam.#PRI.j=kb_per_unit*strip(substr(a.i, 22, 10), "L", "-")
if substr(a.i, 37, 10)^="HI-U-RBA--" then trace '?r'
vsam.#USPACE.j=(strip(substr(a.i, 49, 12), "L", "-")+1023)%1024
i=i+1; if substr(a.i, 8, 10)^="SPACE-SEC-" then trace '?r'
vsam.#SEC.j=kb_per_unit*strip(substr(a.i, 22, 10), "L", "-")
i=i+1; vsam.#XT.j=0; vols=""
/* A file may extend over several volumes - handle all of them */
do while substr(a.i, 6, 8)="VOLUME "
i=i+1; if substr(a.i, 8, 8)^="VOLSER--" then trace '?r'
vols=vols strip(substr(a.i, 22, 10), "L", "-")
if substr(a.i, 95, 14)^="EXTENT-NUMBER-" then trace '?r'
ext=strip(substr(a.i, 113, 6), "L", "-")
vsam.#XT.j=vsam.#XT.j+ext
/* skip lines EXTENTS:, LO-CCHH, HI-CCHH */
i=i+3; if ext>0 then i=i+1+2*ext
end
if vols="" | vsam.#XT.j=0 then trace '?r'
vsam.#VOL.j=strip(vols)
end /* do while substr(a.i, 1, 8)="DATA ---" */
if i<=a.0 then trace '?r'
vsam.0=j
x=time("R")
/*say vsam.0 "Rows, Process Time=" x "seconds."
*/return vsam.0 /* vsaminfo */