Save disk space with confidence! Selectively remove program observability by days.
While we all start off with more disk space than we could ever imagine maxing out, it's amazing how quickly that large amount of space becomes not so large. Removing ob-servability from programs can help you to keep your disk space in tow by eliminating statement number and field cross-reference information from those programs where it's not needed.
Generally, program observability is removed using the Change Program (CHGPGM) command, specifying *ALL for the RMVOBS parameter:
CHGPGM PGM(PGM1) RMVOBS(*ALL)
Removing observability on my system reduced program sizes by impressive amounts; a summary of the space reductions for some of my programs appears in 1.
Removing observability on my system reduced program sizes by impressive amounts; a summary of the space reductions for some of my programs appears in Figure 1.
Though the savings are substantial and may tempt you to go overboard, wide- scale purging of observability quite often results in inconvenience. For instance, interactive debug and trace facilities, as well as system messaging functions, rely on the statement and field information contained in the observability area. Therefore, when observability is removed from a program, debugging commands like Start Debug (STR-DBG) no longer work for that program. Also, if an execution-time error occurs, the error message will not contain the statement number at which the error occurred. And once removed in the traditional manner, observability can be replaced only through the hassle of recompiling the program from source or, in the case of DFU, recreating the program using the command STRDFU OPTION(3).
Considering the loss of debugging facilities and error message information, only programs without bugs should have their observability removed. The best angle of attack should enable the programmer to save storage and feel confident that programs will not fail. That is where the Remove Program Observability (RMVPGMOBS) utility command comes in.
The Program
With the help of a short CL program, observability can selectively be removed from programs based on the date the program was created. The theory here is that if a program was created and placed in production, say, over 60 days ago, it is probably functioning well without problems.
If the program had bugs, we assume someone has performed the necessary maintenance and recompiled the program within the last couple of months. Therefore, if the program is more than 60 days old, we want to remove its observability area to save space.
The CL program uses the Display Object Description (DSPOBJD) command to create a list of programs and QUSRTOOL utility CHKDAT to check the program's creation date. (See "From the Toolbox" in this issue for more information on installing a QUSRTOOL tool.) These two elements work together to accomplish the task of selectively removing observability from programs in production.
First, the RMVPGMOBS command is used to prompt for the necessary parameters. (See 2.) These parameters are fed into command processing program PGM- 004CL, shown in 3.
First, the RMVPGMOBS command is used to prompt for the necessary parameters. (See Figure 2.) These parameters are fed into command processing program PGM- 004CL, shown in Figure 3.
The DSPOBJD command creates an output file of programs, based on the user's selection of program and library names.
The CL program reads the file and, program by program, attempts to remove observability only from those programs that are older than the number of days specified in the &DAYSOLD parameter.
CHKDAT uses the &DAYSOLD parameter to determine if the creation date of the program (&ODCDAT) is within this period of time or not. If not, CHKDAT issues a CPF9898 escape message which is monitored using the Monitor Message (MONMSG) command.
Last but not least, the CHGPGM command is used to actually remove observability from the program. The CHGPGM command is the key to this program. However, it can fail if:
1. Observability has already been removed from the program.
2. The user executing RMVPGMOBS, either directly or through adopted authority, does not have *CHANGE authority to the program and/or at least *USE rights to the library which contains the program.
3. The specified program is in QSYS or QGDDM library.
The CL program PGM004CL attempts to avoid or trap for these possible error conditions through use of MONMSG and the Receive Message (RCVMSG) command. The program sends *DIAG messages as each error is encountered. These stack up on the *PRV (calling program's) message queue and can be seen at the bottom of the screen. Of course, if there is more than one message, you can position the cursor on the message and press the Page Down key to see more. Other potential error conditions are trapped using the global message monitor MONMSG CPF0000.
Because authority errors may prevent this program from functioning to its fullest, it is suggested that the PGM004CL program be compiled with USRPRF(*OWNER), while signed on as QSECOFR or another user profile with *ALLOBJ special authority.
Flexible Enough to Suit Your Needs
If you do not want to be very selective, you can specify zero days old for the DAYSOLD parameter. This will remove observability from all programs older than the current date. In this case, you might as well use CHGPGM directly since it will accept *ALL as the program name.
CHGPGM can be run over only one library, or just the user portion of the library list (*USRLIBL). RMVPGMOBS, on the other hand, allows you to specify *ALLUSR for the library portion of the qualified program name. This lets you selectively remove observability from programs in all the user libraries on your system. Wow!
You cannot specify the job library list (*LIBL) for the library parameter. This is because programs in the system portion of *LIBL would not be eligible for change.
And there you have it: a utility that helps save disk space, but that also logically tries to preserve AS/400 debugging facilities when they might be needed. You'll feel confident that all the kinks have been worked out of the program objects you've tagged as candidates for your space reduction efforts.
Free Up Disk Space by Removing Program Observabili
Figure 1 Program sizes before/after removing observability
Figure 1: Program Sizes Before and After Removing Observability Size Size Space Percent Program Before After Saved Saved IV520C2 10,240 5,120 5,120 50.00 UD035R1 49,152 15,360 33,792 68.75 UD055R 100,864 29,148 71,716 71.10 AR101R 179,712 53,760 125,952 70.09 AR104R 219,648 69,120 150,528 68.53
Free Up Disk Space by Removing Program Observabili
Figure 2 Command RMVPGMOBS
RMVPGMOBS: CMD PROMPT('Remove Program Observability') PARM KWD(PGM) TYPE(QUAL1) MIN(1) PROMPT('Program') PARM KWD(DAYS) TYPE(*DEC) LEN(3) DFT(60) RANGE(0 + 999) PROMPT('Number of days old') QUAL1: QUAL TYPE(*GENERIC) LEN(10) SPCVAL((*ALL)) + EXPR(*YES) QUAL TYPE(*NAME) LEN(10) DFT(*USRLIBL) + SPCVAL((*CURLIB) (*USRLIBL) (*ALLUSR)) + EXPR(*YES) PROMPT('Library')
Free Up Disk Space by Removing Program Observabili
Figure 3 CL program PGM004CL
PGM004CL: + PGM PARM(&PGMLIB &DAYSOLD) DCLF FILE(QADSPOBJ) DCL VAR(&DAYSOLD) TYPE(*DEC) LEN(3 0) DCL VAR(&LIB) TYPE(*CHAR) LEN(10) DCL VAR(&MSGDTA) TYPE(*CHAR) LEN(80) DCL VAR(&MSGF) TYPE(*CHAR) LEN(10) DCL VAR(&MSGFLIB) TYPE(*CHAR) LEN(10) DCL VAR(&MSGID) TYPE(*CHAR) LEN(7) DCL VAR(&PGM) TYPE(*CHAR) LEN(10) DCL VAR(&PGMLIB) TYPE(*CHAR) LEN(20) /* Global error trap */ MONMSG MSGID(CPF0000 MCH0000) EXEC(GOTO CMDLBL(DIAGMSG)) /* Break qualified name of program */ CHGVAR VAR(&PGM) VALUE(%SST(&PGMLIB 1 10)) CHGVAR VAR(&LIB) VALUE(%SST(&PGMLIB 11 10)) /* Programs in QSYS OR QGDDM cannot be changed */ IF COND(&LIB *EQ 'QSYS' *OR &LIB *EQ 'QGDDM') THEN(DO) SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA('Programs in + system library' *BCAT &LIB *BCAT 'cannot be changed') + MSGTYPE(*ESCAPE) RETURN ENDDO /* Turn &DAYSOLD into a negative number */ CHGVAR VAR(&DAYSOLD) VALUE(&DAYSOLD * -1) /* Produce outfile listing all programs requested */ DSPOBJD OBJ(&LIB/&PGM) OBJTYPE(*PGM) DETAIL(*SERVICE) + OUTPUT(*OUTFILE) OUTFILE(QTEMP/QADSPOBJ) OVRDBF FILE(QADSPOBJ) TOFILE(QTEMP/QADSPOBJ) /* For each program... */ READFILE: + RCVF MONMSG MSGID(CPF0864) EXEC(GOTO CMDLBL(EOF)) /* Use CHKDAT to chedk date of creation (&ODCDAT). If &ODCDAT + is older than &DAYSOLD, remove program observability */ TAATOOL/CHKDAT DATE(&ODCDAT) DAYLORNG(&DAYSOLD) DAYHIRNG(0) MONMSG MSGID(CPF9898) EXEC(DO) SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA('Now removing + observability from' *BCAT &ODOBNM) TOPGMQ(*EXT) + MSGTYPE(*STATUS) CHGPGM PGM(&ODLBNM/&ODOBNM) RMVOBS(*ALL) MONMSG MSGID(CPF9821 CPF0547) /* CPF9821: Not authorized. + CPF0547: Cannot remove observability */ RCVMSG MSGTYPE(*LAST) MSGDTA(&MSGDTA) MSGID(&MSGID) + MSGF(&MSGF) SNDMSGFLIB(&MSGFLIB) SNDPGMMSG MSGID(&MSGID) MSGF(&MSGFLIB/&MSGF) MSGDTA(&MSGDTA) MONMSG MSGID(CPF0000) RCVMSG MSGTYPE(*COMP) MSGDTA(&MSGDTA) MSGID(&MSGID) + MSGF(&MSGF) SNDMSGFLIB(&MSGFLIB) SNDPGMMSG MSGID(&MSGID) MSGF(&MSGFLIB/&MSGF) MSGDTA(&MSGDTA) MONMSG MSGID(CPF0000) ENDDO GOTO CMDLBL(READFILE) /* End program when all programs are processed */ EOF: + DLTOVR FILE(QADSPOBJ) MONMSG MSGID(CPF0000) RETURN /* Resend all *DIAG messages */ DIAGMSG: + RCVMSG MSGTYPE(*DIAG) MSGDTA(&MSGDTA) MSGID(&MSGID) MSGF(&MSGF) + SNDMSGFLIB(&MSGFLIB) IF COND(&MSGID *NE ' ') THEN(DO) SNDPGMMSG MSGID(&MSGID) MSGF(&MSGFLIB/&MSGF) MSGDTA(&MSGDTA) + MSGTYPE(*DIAG) GOTO CMDLBL(DIAGMSG) ENDDO /* Resend exception message */ RCVMSG MSGTYPE(*EXCP) MSGDTA(&MSGDTA) MSGID(&MSGID) MSGF(&MSGF) + SNDMSGFLIB(&MSGFLIB) IF COND(&MSGID *NE ' ') THEN(DO) SNDPGMMSG MSGID(&MSGID) MSGF(&MSGFLIB/&MSGF) MSGDTA(&MSGDTA) + MSGTYPE(*ESCAPE) ENDDO ENDPGM
LATEST COMMENTS
MC Press Online