How to delete a user’s spoolfile in batch by date range?

6925 pts.
Tags:
CL
IBM iSeries
OS/400
Spool files
V5R3
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.

Answer Wiki

Thanks. We'll let you know when a new response is added.

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

Discuss This Question: 9  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • tjgm88
    I agree with Phillip's suggestion. Infact, I am writing a CL program as we speak to do the same.
    995 pointsBadges:
    report
  • Cin
    I need a sample CL program for this, anybody can help? Thanks.
    10 pointsBadges:
    report
  • philpl1jb
    I think you'll find some good examples if you search under AS/400 DLTOLDSPLF or AS/400 DLTUSRSPLF
    51,365 pointsBadges:
    report
  • Cwc
    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,290 pointsBadges:
    report
  • slack400
    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,705 pointsBadges:
    report
  • RCOMSTOCK
    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 pointsBadges:
    report
  • AUNumberOne
    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 pointsBadges:
    report
  • Teandy
    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 pointsBadges:
    report
  • WoodEngineer
    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.
    6,875 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following