TechTalk: Deleting Old History Files on the AS/40

Typography
  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times

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 
BLOG COMMENTS POWERED BY DISQUS

LATEST COMMENTS

Support MC Press Online

$

Book Reviews

Resource Center

  •  

  • LANSA Business users want new applications now. Market and regulatory pressures require faster application updates and delivery into production. Your IBM i developers may be approaching retirement, and you see no sure way to fill their positions with experienced developers. In addition, you may be caught between maintaining your existing applications and the uncertainty of moving to something new.

  • The MC Resource Centers bring you the widest selection of white papers, trial software, and on-demand webcasts for you to choose from. >> Review the list of White Papers, Trial Software or On-Demand Webcast at the MC Press Resource Center. >> Add the items to yru Cart and complet he checkout process and submit

  • SB Profound WC 5536Join us for this hour-long webcast that will explore:

  • Fortra IT managers hoping to find new IBM i talent are discovering that the pool of experienced RPG programmers and operators or administrators with intimate knowledge of the operating system and the applications that run on it is small. This begs the question: How will you manage the platform that supports such a big part of your business? This guide offers strategies and software suggestions to help you plan IT staffing and resources and smooth the transition after your AS/400 talent retires. Read on to learn: