zOs/WK/PKGUSFRE

//A540769W JOB (CP00,KE50),'DB2 REO',                                   00010000
//         MSGCLASS=T,TIME=1440,                                        00020000
//         NOTIFY=&SYSUID,REGION=0M                                     00030000
//*MAIN CLASS=LOG0                                                      00040000
//*
//S1       EXEC PGM=IKJEFT01,DYNAMNBR=200,TIME=99,                      00020001
//            PARM='WSH'
//SYSPROC   DD DSN=A540769.WK.REXX,DISP=SHR
//SYSPRINT  DD SYSOUT=*
//SYSUDUMP  DD SYSOUT=*
//SYSTSPRT  DD SYSOUT=*
//OUT       DD SYSOUT=*
//SYSTSIN   DD DUMMY
//WSH       DD *  DISP=SHR,DSN=A540769.TX.CASE(XC200DEL)
$#@
$=subsys=DBOF
$=rz=-sysvar(sysnode)
$=ds2=A540769.wk.texw(pkgusLs2)
$=marA=-''
$=marNo= +?
m.checkCat = 0
if m.checkCat then
    call sqlConnect $subsys
$;
$<=[
A RZ1 DBAF
T RZ1 DBTF
P RZ2 DBOF
Q RR2 DBOF
C RZ8 DC0G
D RZ8 DD0G
E RZZ DE0G
$] $@for sLi $@[
    parse value $sLi with mrk rz sub .
    $=marA =- $marA || mrk
    if $rz == rz & $subsys == sub then
        $=mark =- mrk
    $]
$;
if \ ${?mark} then
    call err 'mark not found for' $rz'.'$subsys
say $rz'.'$subsys'==>'$mark 'marA' $marA 'no' $marNo
verW1 = $marA$marNo
call readDsn $ds2, 'M.INP.'
elaLim = time('e')
cntF = 0
cntN = 0
cntE = 0
say m.inp.0 'recs in' $ds2 'e0' e0
do ix=1     to  m.inp.0
   if time('e') > elaLim then do
       say time() ix 'lines,' cntF 'free,' cntN 'not exist' ,
                              cntE 'errors' cpv
       elaLim = time('e') + 30
       call sleep 10, 0
       end
    parse var m.inp.ix mark cpv c2 .
    if abbrev(mark, '*') then
        iterate
    if verify(mark, verW1) > 0 then
        call err 'bad mark' ix':' m.inp.ix
    if pos($mark, mark) < 1 then
        iterate /* say 'other subsys' elong(mark, 10) cpv */
    else if verify(mark, $marNo, 'm') > 0 then
        iterate /* say 'keep        ' elong(mark, 10) cpv */
    cx = pos('(', cpv)
    if cx > 0 then
        cpv = insert('.', cpv, cx-1)
    rc = sqlDsn(co, $subsys, 'free package (' cpv ')', '*')
    if rc = 0 then do
        cntF = cntF + 1
        end
    else if abbrev(strip(m.co.3), 'PACKAGE =') ,
          & ( abbrev(strip(m.co.4), 'DOES NOT EXIST') ,
            | abbrev(strip(m.co.5), 'DOES NOT EXIST')) then do
        cntN = cntN + 1
        end
    else do
        cntN = cntN + 1
        say 'error' cpv
        do cx=1 to m.co.0
            say m.co.cx
            end
        end
    end
$#out                                              20120203 21:45:42
$#out                                              20120129 12:46:49
$#out                                              20120129 12:20:26
$#out                                              20120129 11:28:22