Uncover objects that have been orphaned, without a source.
Objects created through a compiler are expected to have source code somewhere. For example, if you create a logical file with the Create Logical File (CRTLF) command, the source code is probably in source file QDDSSRC if you use IBM's standard file names.
Many times, however, you'll have objects that have no source code. This usually means that there's something you should be aware of. Maybe you created a "one-time" program and discarded the source code but left the compiled object. Maybe you created a flat physical file with the Create Physical File (CRTPF) command, specifying the record length in the RCDLEN parameter instead of using DDS.
For whatever reason, objects without source ("orphans" as I choose to call them) are likely candidates for deletion. This article presents the List Orphaned Objects (LSTORPOBJ) command (1) and its associated programs and files.
For whatever reason, objects without source ("orphans" as I choose to call them) are likely candidates for deletion. This article presents the List Orphaned Objects (LSTORPOBJ) command (Figure 1) and its associated programs and files.
To run it, simply prompt for LSTORPOBJ and key in the name of the library you wish to analyze. LSTORPOBJ will scan to determine that all objects in that library that should have source (based on their object type) actually do. If they do not, they're listed in a report. You can use the report to see if these objects are still necessary and then take corrective action.
How It Works
CL program ORP001CL (2) produces an outfile in QTEMP which has one record for each object in the library-whether the object should have source or not (data areas, for instance, don't require any source code). Then it creates work file ORP001WF in QTEMP by copying the model file (3).
CL program ORP001CL (Figure 2) produces an outfile in QTEMP which has one record for each object in the library-whether the object should have source or not (data areas, for instance, don't require any source code). Then it creates work file ORP001WF in QTEMP by copying the model file (Figure 3).
The loop that follows processes one object at a time. The name of the source file used at the time the object was created is contained in &ODSRCF. If &ODSRCF is blank, it's because the object doesn't require source code-like a user profile or job description-so it loops again, ignoring the object. If not, the Retrieve Member Description (RTVMBRD) command attempts to find the source member from which the object was created.
If RTVMBRD fails, there's no source member. In this case, program ORP001RG (4) writes a record to the work file. This work file will have one record for each object without source. When all objects have been processed, program ORP001RGA (6) prints the report, using printer file ORP001P1 (5).
If RTVMBRD fails, there's no source member. In this case, program ORP001RG (Figure 4) writes a record to the work file. This work file will have one record for each object without source. When all objects have been processed, program ORP001RGA (Figure 6) prints the report, using printer file ORP001P1 (Figure 5).
Try It
LSTORPOBJ works even if the compiled objects are moved to another library after creation, since the compiled object carries within itself the name of the original source file and member. It won't work, however, if you move the source code to another source file or library after creation.
LSTORPOBJ is simple to use and lets you find abnormal situations, ultimately saving you disk space. We've found that it is an invaluable tool in our shop.
List Orphaned Objects
Figure 1 Command LSTORPOBJ
LSTORPOBJ: CMD PROMPT('List Orphaned Objects') PARM KWD(LIB) TYPE(*NAME) LEN(10) MIN(1) + EXPR(*YES) PROMPT('Library to inspect')
List Orphaned Objects
Figure 2 CL program ORP001CL
ORP001CL: + PGM PARM(&LIB) DCL VAR(&LIB) TYPE(*CHAR) LEN(10) DCL VAR(&SYS) TYPE(*CHAR) LEN(4) DCL VAR(&MSGDTA) TYPE(*CHAR) LEN(90) DCL VAR(&MSGF) TYPE(*CHAR) LEN(10) DCL VAR(&MSGFLIB) TYPE(*CHAR) LEN(10) DCL VAR(&MSGID) TYPE(*CHAR) LEN(7) DCL VAR(&RTNLIB) TYPE(*CHAR) LEN(10) DCLF FILE(QADSPOBJ) MONMSG MSGID(CPF0000) EXEC(GOTO CMDLBL(SNDERRMSG)) DSPOBJD OBJ(&LIB/*ALL) OBJTYPE(*ALL) DETAIL(*SERVICE) + OUTPUT(*OUTFILE) OUTFILE(QTEMP/QADSPOBJ) OUTMBR(*FIRST *REPLACE) OVRDBF FILE(QADSPOBJ) TOFILE(QTEMP/QADSPOBJ) RTVOBJD OBJ(ORP001WF) OBJTYPE(*FILE) RTNLIB(&RTNLIB) CRTDUPOBJ OBJ(ORP001WF) FROMLIB(&RTNLIB) OBJTYPE(*FILE) + TOLIB(QTEMP) NEWOBJ(*OBJ) DATA(*NO) MONMSG MSGID(CPF0000) CLRPFM FILE(QTEMP/ORP001WF) OVRDBF FILE(ORP001WF) TOFILE(QTEMP/ORP001WF) RCVF: + RCVF MONMSG MSGID(CPF0000) EXEC(GOTO CMDLBL(PRTORPS)) IF COND(&ODSRCF *EQ ' ') THEN(GOTO CMDLBL(RCVF)) RTVMBRD FILE(&ODSRCL/&ODSRCF) MBR(&ODSRCM) RTNSYSTEM(&SYS) MONMSG MSGID(CPF0000) EXEC(DO) CALL PGM(ORP001RG) PARM(&ODLBNM &ODOBNM &ODOBTP &ODOBAT + &ODOBTX &ODSRCF &ODSRCL &ODSRCM) ENDDO GOTO CMDLBL(RCVF) PRTORPS: + CALL PGM(ORP001RGA) PARM(&LIB) RCLRSC RETURN SNDERRMSG: + RCVMSG MSGTYPE(*EXCP) MSGDTA(&MSGDTA) MSGID(&MSGID) MSGF(&MSGF) + MSGFLIB(&MSGFLIB) SNDPGMMSG MSGID(&MSGID) MSGF(&MSGFLIB/&MSGF) MSGDTA(&MSGDTA) + MSGTYPE(*ESCAPE) ENDPGM
List Orphaned Objects
Figure 3 Physical file ORP001WF
A REF(QADSPOBJ) A R ORPREC A ODLBNM R A ODOBNM R A ODOBTP R A ODOBAT R A ODOBTX R A ODSRCF R A ODSRCL R A ODSRCM R
List Orphaned Objects
Figure 4 RPG program ORP001RG
FORP001WFO E DISK A * C *ENTRY PLIST C PARM ODLBNM C PARM ODOBNM C PARM ODOBTP C PARM ODOBAT C PARM ODOBTX C PARM ODSRCF C PARM ODSRCL C PARM ODSRCM * C WRITEORPREC C SETON LR
List Orphaned Objects
Figure 5 Printer file ORP001P1
A REF(ORP001WF) * A R HEADER SKIPB(3) A 1'Date:' A +2DATE EDTCDE(Y) A 42'Orphaned Objects Report' A 119'Page:' A +2PAGNBR EDTCDE(J) A SPACEA(1) A 42'Scanned library is' A LIBNAM 10 +1 A 119'Time:' A +1TIME A SPACEA(1) A DASH1 132 1 A SPACEA(1) A 1'Library Object' A 25'Type Attribute' A 47'Object Text' A 100'Src File Library' A 123'Member' A SPACEA(1) A DASH2 132 1 A SPACEA(2) * A R DETAIL A ODLBNM R 1 A ODOBNM R 13 A ODOBTP R 25 A ODOBAT R 35 A ODOBTX R 47 A ODSRCF R 100 A ODSRCL R 111 A ODSRCM R 123 A SPACEA(1)
List Orphaned Objects
Figure 6 RPG program ORP001RGA
FORP001WFIP E DISK FORP001P1O E 99 PRINTER * C *IN99 IFEQ '1' C WRITEHEADER C MOVE '0' *IN99 C END * C WRITEDETAIL * C *INZSR BEGSR C *ENTRY PLIST C PARM LIBNAM 10 C MOVE *ALL'-' DASH1 132 C MOVE *ALL'-' DASH2 132 C WRITEHEADER C ENDSR
LATEST COMMENTS
MC Press Online