Saving DASD space is a legitimate concern in typical AS/400 installations. Reclaiming wasted space by deleted records in physical files can significantly increase your available space, especially if your files are many and large; this space is reclaimed by reorganizing the database files.
OS/400 has given us the Reorganize Physical File Member (RGZPFM) command, which eliminates deleted records from a single member in a physical file. In the July issue, Midrange Computing published a utility to reorganize all members of a physical file with a single command, RGZPFMALL. To improve beyond that, we need another utility to reorganize all physical files in a library.
That is the purpose of the Reorganize All Physical Files command (RGZALLPF). This command (see 1) has two parameters: library name and member. With RGZALLPF, you can reorganize all members in all physical files in a library -- with a single command -- or just the first or last member of all files.
That is the purpose of the Reorganize All Physical Files command (RGZALLPF). This command (see Figure 1) has two parameters: library name and member. With RGZALLPF, you can reorganize all members in all physical files in a library -- with a single command -- or just the first or last member of all files.
The command processing program is shown in 2. It uses the DSPOBJD command to an outfile in order to obtain the names of all files located in the library that you selected. Because this program uses command RGZPFMALL (from the July issue), you should load it into your system before using RGZALLPF.
The command processing program is shown in Figure 2. It uses the DSPOBJD command to an outfile in order to obtain the names of all files located in the library that you selected. Because this program uses command RGZPFMALL (from the July issue), you should load it into your system before using RGZALLPF.
Using RGZALLPF is easy, although it may take a considerable amount of time, depending on the number of physical files in your libraries and the number of members in each file. Consider running RGZALLPF only in batch mode.
For example, you can easily reorganize all members in all the physical files contained in library MYLIB by executing the following command:
SBMJOB CMD(RGZALLPF LIB(MYLIB) MBR(*ALL))
Because deleted records have a tendency to accumulate, you can reclaim considerable space by running the RGZALLPF periodically. Make it part of your weekly system housekeeping jobs!
Keep Your Files Organized
Figure 1 Command RGZALLPF
RGZALLPF: CMD PROMPT('Reorganize All Physical Files') PARM KWD(LIB) TYPE(*SNAME) LEN(10) MIN(1) + PROMPT('Library name') PARM KWD(MBR) TYPE(*CHAR) LEN(6) RSTD(*YES) + DFT(*ALL) VALUES(*ALL *FIRST *LAST) + PROMPT('Member')
Keep Your Files Organized
Figure 2 CL program ALL001CL
ALL001CL: + PGM PARM(&LIB &MBR) DCL VAR(&LIB) TYPE(*CHAR) LEN(10) DCL VAR(&MBR) TYPE(*CHAR) LEN(6) 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(&NORGZ) TYPE(*DEC) LEN(5 0) DCL VAR(&NORGZCHAR) TYPE(*CHAR) LEN(5) DCL VAR(&RGZ) TYPE(*DEC) LEN(5 0) DCL VAR(&RGZCHAR) TYPE(*CHAR) LEN(5) DCLF FILE(QADSPOBJ) MONMSG MSGID(CPF0000) EXEC(GOTO CMDLBL(SNDERRMSG)) DSPOBJD OBJ(&LIB/*ALL) OBJTYPE(*FILE) OUTPUT(*OUTFILE) + OUTFILE(QTEMP/QADSPOBJ) OVRDBF FILE(QADSPOBJ) TOFILE(QTEMP/QADSPOBJ) LOOP: + RCVF MONMSG MSGID(CPF0864) EXEC(GOTO CMDLBL(END_LOOP)) IF COND(&ODOBAT *EQ 'PF') THEN(DO) /* Reorganize all members */ IF COND(&MBR *EQ '*ALL') THEN(DO) RGZPFMALL FILE(&LIB/&ODOBNM) MONMSG MSGID(CPF0000) EXEC(DO) SNDPGMMSG MSG('File' *BCAT &ODOBNM *BCAT 'not + reorganized.') MSGTYPE(*DIAG) CHGVAR VAR(&NORGZ) VALUE(&NORGZ + 1) GOTO CMDLBL(LOOP) ENDDO ENDDO /* Reorganize one member */ ELSE CMD(DO) RGZPFM FILE(&LIB/&ODOBNM) MBR(&MBR) MONMSG MSGID(CPF0000) EXEC(DO) SNDPGMMSG MSG('File' *BCAT &ODOBNM *BCAT 'not + reorganized.') MSGTYPE(*DIAG) CHGVAR VAR(&NORGZ) VALUE(&NORGZ + 1) GOTO CMDLBL(LOOP) ENDDO ENDDO CHGVAR VAR(&RGZ) VALUE(&RGZ + 1) ENDDO GOTO CMDLBL(LOOP) END_LOOP: + CHGVAR VAR(&RGZCHAR) VALUE(&RGZ) CHGVAR VAR(&NORGZCHAR) VALUE(&NORGZ) SNDPGMMSG MSG('RGZALLPF LIB(' *CAT &LIB *TCAT ') MBR(' *CAT &MBR + *TCAT ') is complete.') MSGTYPE(*COMP) SNDPGMMSG MSG(&RGZCHAR *BCAT 'files reorganized.') MSGTYPE(*COMP) SNDPGMMSG MSG(&NORGZCHAR *BCAT 'files not reorganized.') + MSGTYPE(*COMP) GOTO CMDLBL(ENDPGM) SNDERRMSG: + RCVMSG MSGTYPE(*EXCP) RMV(*NO) MSGDTA(&MSGDTA) MSGID(&MSGID) + MSGF(&MSGF) MSGFLIB(&MSGFLIB) IF COND(&MSGID *NE ' ') THEN(DO) SNDPGMMSG MSGID(&MSGID) MSGF(&MSGFLIB/&MSGF) MSGDTA(&MSGDTA) + MSGTYPE(*DIAG) SNDPGMMSG MSGID(CPF0002) MSGF(QCPFMSG) MSGTYPE(*ESCAPE) ENDDO ENDPGM: + ENDPGM
LATEST COMMENTS
MC Press Online