/* REXX Exec Specifications ******************************************\ * * * Syntax: CSDORPHN dsnipt dsnout dbugopt * * * * where: dsnipt = Fully qualified DSName of the DFHCSDUP * * "LIST ALL" report file on disk * * dsnout = Optional, fully qualified DSName * * of the output dataset from this exec. * * Default is extracted from dsnipt * * dbugopt= Optional, specify a standard TRACE option * * for debugging if something seems amiss. * * * *----------------------------------------------------------------------* * * * Function: Read a sequential disk file that was created by the * * DFHCSDUP LIST ALL utility and create a list of CSD * * GROUPs that are not referenced or included in any * * application LIST; i.e. orphan groups. * * * * Input: Sequential file; ex - HLQ.DFHCSD.LISTING * * Output: Sequential file; ex - HLQ.DFHCSD.ORPHANS * * * *----------------------------------------------------------------------* * Notes: The list of ORPHAN groups is in SYSIN format so that it * * may be used as a SYSIN dataset to a subsequent DFHCSDUP * * job to delete the orphan groups from a CSD. Of course, * * deleting an orphan group will automatically delete any * * orphan program, file, etc. - whatever was defined in the * * original group definition. * *----------------------------------------------------------------------* * Author: Stephen Buckles * * Date Written: Years ago * * * * \* End Specifiations **************************************************/ orphanmsg= "Orphan GROUPS were found in" hivalues = 'ffffffffffffffff'x dup_sw = 0 grpcount = 0 lstcount = 0 tic = "'" /* For clarity in later code */ dot = "." /* For clarity in later code */ arg dsnipt dsnout dbugopt if dbugopt = '' then nop else interpret trace dbugopt select; when dsnipt = "?" then signal csd_help when dsnipt = "" then do 1; say "Enter DSName of input file:" pull dsnipt end; otherwise nop end; dsnipt = strip(dsnipt,,tic) /* Strip Apostrophes from DSNames */ dsnout = strip(dsnout,,tic) select; when dsnout = '' then dsnout = left(dsnipt,lastpos(dot,dsnipt)) || "ORPHANS" when length(dsnout) < 9 then dsnout = left(dsnipt,lastpos(dot,dsnipt)) || dsnout otherwise nop end; dsnipt = tic||dsnipt||tic /* Put apostrophes back on DSNames */ dsnout = tic||dsnout||tic orgipt = dsnipt /* Save Original Name for final msg */ ADDRESS TSO /* Route non-REXX commmands to TSO */ CLRSCRN "ALLOCATE DATASET ("dsnipt") FILE(DDIPT) SHR" "EXECIO * DISKR DDIPT (STEM iptrcd. FINIS" "FREE FILE(DDIPT)" say iptrcd.0 "records have been read from" dsnipt say "Do you wish to continue execution: Y or N?" pull answer if answer = "Y" then nop else exit newstack do i = 1 to iptrcd.0 by 1 select; when substr(iptrcd.i,2,10) = "LIST NAME:" then do 1; listname = substr(iptrcd.i,17,8) lstcount = lstcount+1 end; when substr(iptrcd.i,2,11) = "GROUP NAME:" then do 1; outrcd = substr(iptrcd.i,14,8) hivalues grpcount = grpcount+1 queue outrcd end; when substr(iptrcd.i,6,5) = "GROUP" then do 1; outrcd = substr(iptrcd.i,17,8) listname queue outrcd end; otherwise nop end; end; call write_output_records delstack say " LIST count in CSD: " right(lstcount,5) say "GROUP count in CSD: " right(grpcount,5) "ISPEXEC EDIT DATASET("dsnout") MACRO(CSDSORT)" dsnipt = dsnout "ALLOCATE DATASET ("dsnipt") FILE(DDIPT) OLD" "EXECIO * DISKR DDIPT (STEM iptrcd. FINIS" "FREE FILE(DDIPT)" say iptrcd.0 "records have been read from" dsnipt say "" newstack queue "****** Orphan GROUPS - those not included in any LIST ******" do i = 1 to iptrcd.0 by 1 a_rcd = substr(iptrcd.i,1,8) j =i+1 if i = iptrcd.0 then b_rcd = hi_values else b_rcd = substr(iptrcd.j,1,8) select; when substr(a_rcd,1,3) = "DFH" then nop when a_rcd = b_rcd then dup_sw = 1 otherwise do 1; if dup_sw = 0 then queue "DELETE GROUP(" || a_rcd || ")" else dup_sw = 0 end; end; end; if queued() < 2 then do 1; say "Zero" orphanmsg orgipt call write_output_records end; else do 1; say queued()-1 orphanmsg orgipt call write_output_records end; delstack exit 0 /* Standalone Subroutines ********************************************/ CSD_HELP: i = 1 do until pos('End Spec',sourceline(i)) > 0 say sourceline(i) i = i+1 end; say sourceline(i) exit 0 WRITE_OUTPUT_RECORDS: ddspace = "DSORG(PS) SPACE(15,15) TRACKS LRECL(80)" ddspace = ddspace "BLKSIZE(7040) RECFM(F,B)" if SYSDSN(dsnout) = "OK" then ddout_disp = "OLD REUSE" else ddout_disp = "NEW" ddspace "ALLOCATE DATASET ("dsnout") FILE(DDOUT)" ddout_disp "EXECIO" queued() "DISKW DDOUT (FINIS" "FREE FILE(DDOUT)" return rc :End CSDORPHN.EXEC