OS/400 provides two commands you can use to reduce the amount of DASD used by your application programs: Reorganize Physical File Member (RGZPFM) and Clear Physical File Member (CLRPFM).
Both commands accept a specific member name, *FIRST, or *LAST. Since neither command accepts *ALL, your "house-cleaning" can become more difficult than it has to be, especially if you keep multi-member physical files.
Weep no more! Commands Clear Physical File, all members (CLRPFMALL) and Reorganize Physical File, all members (RGZPFMALL) process all members of a database file.
3a and 3b show the command definition for CLRPFMALL and RGZPFMALL, respectively. Notice that the second parameter has been defined as being a constant. Both commands share the same command processing program (PFM001CL, in 3c). This second parameter tells the CPP whether to clear all members or reorganize all members. This second parameter is invisible to the user -- the command prompter will not display it.
Figures 3a and 3b show the command definition for CLRPFMALL and RGZPFMALL, respectively. Notice that the second parameter has been defined as being a constant. Both commands share the same command processing program (PFM001CL, in Figure 3c). This second parameter tells the CPP whether to clear all members or reorganize all members. This second parameter is invisible to the user -- the command prompter will not display it.
The logic of program PFM001CL is actually quite simple. Retrieve the name of the first member with RTVMBRD MBR(*FIRST) RTNMBR(&RTNMBR). Now, variable &RTNMBR contains the name of the first member. The program goes into a loop that runs either CLRPFM or RGZPFM on this member. This is followed by another RTVMBRD to retrieve the name of the next member using MBR(&RTNMBR *NEXT) meaning the member that follows &RTNMBR . The name of this member is placed, again, in &RTNMBR -- and the loop continues until all members have been processed.
TechTalk: Clearing/Reorganizing All Members
Figure 3A Command CLRPFMALL
CLRPFMALL: CMD PROMPT('Clear all File Members') PARM KWD(FILE) TYPE(Q1) MIN(1) PROMPT('File name') PARM KWD(ACTION) TYPE(*CHAR) LEN(4) CONSTANT(*CLR) Q1: QUAL TYPE(*SNAME) LEN(10) MIN(1) QUAL TYPE(*SNAME) LEN(10) DFT(*LIBL) + SPCVAL((*LIBL)) PROMPT('Library')
TechTalk: Clearing/Reorganizing All Members
Figure 3B Command RGZPFMALL
RGZPFMALL: CMD PROMPT('Reorganize All Members') PARM KWD(FILE) TYPE(Q1) MIN(1) PROMPT('File name') PARM KWD(ACTION) TYPE(*CHAR) LEN(4) CONSTANT(*RGZ) Q1: QUAL TYPE(*SNAME) LEN(10) MIN(1) QUAL TYPE(*SNAME) LEN(10) DFT(*LIBL) + SPCVAL((*LIBL)) PROMPT('Library')
TechTalk: Clearing/Reorganizing All Members
Figure 3C CL program PFM001CL
PFM001CL: + PGM PARM(&QF &ACTION) DCL VAR(&ACTION) TYPE(*CHAR) LEN(4) DCL VAR(&FILE) TYPE(*CHAR) LEN(10) DCL VAR(&LIB) TYPE(*CHAR) LEN(10) DCL VAR(&MSGDTA) TYPE(*CHAR) LEN(80) DCL VAR(&MSGID) TYPE(*CHAR) LEN(7) DCL VAR(&MSGF) TYPE(*CHAR) LEN(10) DCL VAR(&MSGFLIB) TYPE(*CHAR) LEN(10) DCL VAR(&QF) TYPE(*CHAR) LEN(20) DCL VAR(&RTNMBR) TYPE(*CHAR) LEN(10) MONMSG MSGID(CPF0000) EXEC(GOTO CMDLBL(SNDERRMSG)) CHGVAR VAR(&FILE) VALUE(%SST(&QF 1 10)) CHGVAR VAR(&LIB) VALUE(%SST(&QF 11 10)) CHKOBJ OBJ(&LIB/&FILE) OBJTYPE(*FILE) AUT(*OBJMGT) RTVMBRD FILE(&LIB/&FILE) MBR(*FIRST) RTNMBR(&RTNMBR) MONMSG MSGID(CPF0000) EXEC(DO) SNDPGMMSG MSG('File' *BCAT &FILE *BCAT 'has no members.') + MSGTYPE(*INFO) GOTO CMDLBL(ENDPGM) ENDDO LOOP: + IF COND(&ACTION *EQ '*CLR') THEN(DO) SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA('Clearing + member' *BCAT &RTNMBR *BCAT 'from file' *BCAT &FILE) + TOPGMQ(*EXT) MSGTYPE(*STATUS) CLRPFM FILE(&LIB/&FILE) MBR(&RTNMBR) MONMSG MSGID(CPF0000) ENDDO ELSE CMD(DO) SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA('Reorganizing + member' *BCAT &RTNMBR *BCAT 'from file' *BCAT &FILE) + TOPGMQ(*EXT) MSGTYPE(*STATUS) RGZPFM FILE(&LIB/&FILE) MBR(&RTNMBR) MONMSG MSGID(CPF0000) ENDDO RTVMBRD FILE(&LIB/&FILE) MBR(&RTNMBR *NEXT) RTNMBR(&RTNMBR) MONMSG MSGID(CPF0000) EXEC(DO) SNDPGMMSG MSG('All members of file' *BCAT &FILE *BCAT + 'processed successfully.') MSGTYPE(*INFO) GOTO CMDLBL(ENDPGM) ENDDO GOTO CMDLBL(LOOP) SNDERRMSG: + RCVMSG MSGTYPE(*LAST) MSGDTA(&MSGDTA) MSGID(&MSGID) MSGF(&MSGF) + MSGFLIB(&MSGFLIB) SNDPGMMSG MSGID(&MSGID) MSGF(&MSGFLIB/&MSGF) MSGDTA(&MSGDTA) + MSGTYPE(*DIAG) SNDPGMMSG MSGID(CPF0002) MSGF(QCPFMSG) MSGTYPE(*ESCAPE) ENDPGM: + ENDPGM
LATEST COMMENTS
MC Press Online