We all know by now that old history files should be periodically deleted. The CL program RMVHIST (1) will help you do that and will allow you to specify the number of history files you want to keep.
We all know by now that old history files should be periodically deleted. The CL program RMVHIST (Figure 1) will help you do that and will allow you to specify the number of history files you want to keep.
To delete history files, enter CALL REVHIST 'x', where x is the number of history files to retain. For example, to delete all but the last two history files, type the following: CALL HIST1 '2'.
The Program uses the display object description command to create an outfile with all the QHST* files. The Retrieve Member Description command (RTVMBRD) is used to retrieve the number of records in the file and calculate the number of records to be deleted. The outfile is read until the number of records to delete has been read. The variable count is used to count the number of deleted files. After the required number of files have been deleted, the file is closed by issuing the RCLRSC command (since the file was not opened we cannot use the CLOF command to close it). The counter is adjusted by -1 to show the actual number of deleted files, and is moved to a character field to be edited. The editing loop (LOOP1) scans &COUNTA field, left to right, until the first non-zero character is found, and then replaces each zero with a space. A completion message is used to indicate the number of files deleted.
Alon Fluxman Highlands Ranch, Colorado
TechTalk: Deleting Old History Files on the AS/40
Figure 1 CL program RMVHIST
RMVHIST: + PGM PARM(&KEEP) DCLF FILE(QSYS/QADSPOBJ) /* IBM FILE TO BE OVERRIDDEN */ DCL VAR(&NBRRCD) TYPE(*DEC) LEN(10 0) DCL VAR(&COUNT ) TYPE(*DEC) LEN(10 0) VALUE(0) DCL VAR(&COUNTA) TYPE(*CHAR) LEN(10) DCL VAR(&KEEP ) TYPE(*CHAR)LEN(2) DCL VAR(&KEEPN ) TYPE(*DEC) LEN(3 0) DCL VAR(&IDX ) TYPE(*DEC) LEN(2 0) /* Move number of days to a numeric field */ CHGVAR VAR(&KEEPN) VALUE(&KEEP) DSPOBJD OBJ(QSYS/QHST*) OBJTYPE(*FILE) OUTPUT(*OUTFILE) + OUTFILE(QTEMP/DSPOUTP) /* Delete log loop */ OVRDBF FILE(QADSPOBJ) TOFILE(QTEMP/DSPOUTP) RTVMBRD FILE(QTEMP/DSPOUTP) NBRCURRCD(&NBRRCD) IF COND(&KEEPN *EQ 0) THEN(CHGVAR VAR(&KEEPN) VALUE(2)) CHGVAR VAR(&NBRRCD) VALUE(&NBRRCD - &KEEPN) IF COND(&NBRRCD *GT 0) THEN(DO) LOOP: + RCVF RCDFMT(QLIDOBJD) /* DSPOBJD FORMAT */ MONMSG MSGID(CPF0864) EXEC(GOTO CMDLBL(END)) CHGVAR VAR(&COUNT) VALUE(&COUNT +1) IF COND(&COUNT *GT &NBRRCD) THEN(GOTO CMDLBL(END)) DLTF FILE(QSYS/&ODOBNM) /* DELETE THE LOG FILE */ GOTO CMDLBL(LOOP) ENDDO END: + RCLRSC LVL(*CALLER) DLTF FILE(QTEMP/DSPOUTP) IF COND(&COUNT *GT 1) THEN(CHGVAR VAR(&COUNT) VALUE(&COUNT - 1)) CHGVAR VAR(&COUNTA) VALUE(&COUNT) CHGVAR VAR(&IDX) VALUE(1) /* Edit output field */ LOOP1: + IF COND(%SST(&COUNTA &IDX 1) *EQ '0') THEN(DO) CHGVAR VAR(%SST(&COUNTA &IDX 1)) VALUE(' ') CHGVAR VAR(&IDX) VALUE(&IDX + 1) IF COND(&IDX *LT 10) THEN(GOTO CMDLBL(LOOP1)) /* EDIT OUTPUT */ ENDDO SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA(&COUNTA *BCAT + 'FILES WERE DELETED') MSGTYPE(*COMP) ENDPGM
LATEST COMMENTS
MC Press Online