6,580 pts.
 How to delete a user’s spoolfile in batch by date range?
Would like to know is there a way to delete a user's spool file in batch by date range? Is there any CL I can refer to.Please help. FYI, my iSeries model = 20 running on OS/400 V5R3M0. Thank you in advance for your help. Mod Note: This question was submitted to our Moderator mailbox.

Software/Hardware used:
ASKED: October 15, 2008  3:52 PM
UPDATED: October 29, 2009  4:29 PM

Answer Wiki:
We currently use the below CL and it works great - Adam V. <pre> PGM /* Declare Files and Variables */ DCL VAR(&SPLDAYSOLD) TYPE(*DEC) LEN(2 0) VALUE(-14) DCL VAR(&NEWDATE) TYPE(*CHAR) LEN(6) DCL VAR(&CYMDDATE) TYPE(*CHAR) LEN(8) DCL VAR(&SPLDATE) TYPE(*CHAR) LEN(8) CVTOUTQ OUTQ(QPRINT) OUTLIB(QGPL) MONMSG MSGID(CPF2479) MONMSG MSGID(CPF4903) MONMSG MSGID(CPF9898) MONMSG MSGID(CPF9999) CVTOUTQ OUTQ(OPTIOWO01) OUTLIB(QGPL) REPLACE(*NO) MONMSG MSGID(CPF2479) MONMSG MSGID(CPF4903) MONMSG MSGID(CPF9898) MONMSG MSGID(CPF9999) /* more queues here, etc....*/ DCLF FILE(*LIBL/OUTQP) /* Setup the date for deleting the spool files */ ADDDAT DAYS(&SPLDAYSOLD) TOVAR(&NEWDATE) CVTDAT DATE(&NEWDATE) TOVAR(&CYMDDATE) FROMFMT(*MDY) + TOFMT(*YYMD) TOSEP(*NONE) /* Read through the spoolfiles and determine which should be */ /* purged based on the date ord User Data... */ READ: RCVF MONMSG MSGID(CPF0864) EXEC(GOTO CMDLBL(EOF)) CVTDAT DATE(&SPDAT) TOVAR(&SPLDATE) FROMFMT(*YMD) + TOFMT(*YYMD) TOSEP(*NONE) IF COND(&SPLDATE *LE &CYMDDATE *AND &SPUDTA *NE + 'DALYSALE' *AND &SPUDTA *NE 'PRODUCTION') + THEN(DO) DLTSPLF FILE(&SPFILE) JOB(&SPJNBR/&SPUSER/&SPJNAM) + SPLNBR(&SPFNBR) MONMSG MSGID(CPF0000) ENDDO GOTO CMDLBL(READ) EOF: CLRPFM FILE(*LIBL/OUTQP) MONMSG MSGID(CPF0000) ENDPGM </pre> //////////////////////////////////////////////////////////////////////////////// hi AUNumberOne These commands are in TAATOOL's - if you don't have it you should. CVTOUTQ - do a wrkoutq to *print - cpySPLF to a flat file then as you read the file you will need to substring for the info you need ADDDAT Today is 03/06/09 if I wanted to delete everything 10 days old how can you compute that date to compare with the date from the record you're reading. - little RPG program or some 20 lines of cl to compute the date. You will probably need to use CVTDAT on the record date to put it in a useable format. Phil
Last Wiki Answer Submitted:  March 6, 2009  4:18 pm  by  AdamVanBuskirk   85 pts.
All Answer Wiki Contributors:  AdamVanBuskirk   85 pts. , ITKE   16,755 pts. , philpl1jb   44,630 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

I agree with Phillip’s suggestion. Infact, I am writing a CL program as we speak to do the same.

 980 pts.

 

I need a sample CL program for this, anybody can help? Thanks.

 10 pts.

 

I think you’ll find some good examples if you search under
AS/400 DLTOLDSPLF or AS/400 DLTUSRSPLF

 44,630 pts.

 

Or, if you’d like the flexibility of using APIs:

There is an API, QUSLSPL, that will produce a list of spool files which have the critiera you specify through its paramameters. This list would be written to a user space. From an RPG program (or COBOL, or whatever your preferred language is), you could read through those entries and delete them. But I haven’t been able to find an API to delete a spool file, so you could use the QCMDEXEC method, although it seems a bit roundabout to me. Or, as each entry is read, you could move it to an out queue via the QSPMOVSP API. Afterwards, you could clear that out queue.

 4,275 pts.

 

If you happen to have TAATOOLS on your system there are a couple of utility programs that you can use to do this. It would save some time over writing it from scratch.

(Every shop I visit seems to always have a 10 year old version of TAATOOLS)

 2,680 pts.

 

Check out DLTSPLFDAT. Herman Van Der Staey wrote a utility using the api. Not only is it a good tool but it has the techniques in it so that if you want to modify it for workspace specific tasks (such as moving old spoolfiles to a specific outq, changing spool attributes, etc).

 25 pts.

 

I used the code above and the library at my company does not have the commands CVTOUTQ and ADDDAT. Is there any other commands I can use to make this code capture and delete spool files after a certain amount of days?

 10 pts.

 

The CVTOUTQ & ADDDAT commands are part of TAATOOLS which was a licensed product from IBM but has since been dropped. Jim Sloan was the original author and I believe he took it with him when he left IBM. I’m not sure if you can still buy a copy or not.

 5,860 pts.

 

Check out IBM’s DLTOLDSPLF. It includes a parm for days to retain a spool file. We use it exactly as you describe. Works great.

The code should be available for download from IBM.

 5,570 pts.