It's the end of the year, so now is a good time to clean up your DASD. Often, I find that when I create a compiler listing or sample report, I leave the corresponding spool file out there for what seems like forever. So I created the Delete My Old Spool Files (DLTOLDSPLF) command.
The DLTOLDSPLF command allows you to easily clean up older, unneeded spool files. You pass in the number of days old a spool file has to be before it is deleted and optionally a user profile name, and poof, they're gone!
To delete my own spool files that are at least 30 days old, I would run the following command:
Of course, you should only delete your own user profile's spool files, so the USRPRF parameter defaults to USRPRF(*CURRENT). But because we're programmers, we can, of course, delete almost anything we want (Sarbanes-Oxley, turn your head for a second). To delete all the spool files that are at least 60 days old for the user profile named BOB, you would run the following command:
Provided you have regular OS/400 or i5/OS authorization to these spool files, poof, they're gone!
I'm using the CRTSPLLIST() procedure from the xTools *SRVPGM to build the list of spool file entries. If you don't have that service program installed, you can call the QUSLSPL API, the prototype for which is included at the end of this article. Using the CRTSPLLIST procedure reduces the parameters that I need to specify. It also saves space in this newsletter and allows me to publish more powerful code with fewer statements. In a few weeks, I will present the Delete Old IFS Files (DLTOLDIFS) command, which deletes files from a specific directory of the IFS once they become a specified number of days old.
The source code for DLTOLDSPLF is available online, but I have reproduced it here.
The command definition source code for the DLTOLDSPLF command is listed below.
/* Command processing program is: DLTOLDSPLF */
PARM KWD(DAYS) TYPE(*UINT2) DFT(14) EXPR(*YES) +
PROMPT('Number of days to qualify')
PARM KWD(USRPRF) TYPE(*NAME) LEN(10) +
DFT(*CURRENT) SPCVAL((*CURRENT)) +
EXPR(*YES) PROMPT('User profile')
To view this source member online or to download it directly, follow this link.
The RPG IV source code for the DLTOLDSPLF program is listed below:
|
To view this source member online or to download it directly, follow this link.
The prototype for the QUSLSPL API is as follows:
** E N U M E R A T E S P O O L F I L E N A M E S L I S T
*********************************************************
D QUSLSPL PR ExtPgm('QUSLSPL')
D szUserSpace 20A Const
D Format 8A Const
D UserName 10A Const
D OutQ 20A Const
D FormType 10A Const
D UserData 10A Const
D apiError Like(QUSEC) OPTIONS(*NOPASS)
D JobID 26A Const OPTIONS(*NOPASS)
D RtnFldKeys 10I 0 Const OPTIONS(*NOPASS)
D Dim(24)
D FldKeyCnt 10I 0 Const OPTIONS(*NOPASS)
D ASP 10I 0 Const OPTIONS(*NOPASS)
Bob Cozzi is a programmer/consultant, writer/author, and software developer. His popular RPG xTools add-on subprocedure library for RPG IV is fast becoming a standard with RPG developers. His book The Modern RPG Language has been the most widely used RPG programming book for more than a decade. He, along with others, speaks at and produces the highly popular RPG World conference for RPG programmers.
LATEST COMMENTS
MC Press Online