Delete Spool Files of 30 users (Starting with OP) using Generic Name i.e. OP*

215 pts.
AS/400 Spool Files
Spool files
Every 3 moths we are deleting Spool files of users Starting With OP, on iSeries System using the below Program and a Display File.

This activity is performed after the Spool Files (Which needs to be deleted) are saved on Tape using BRMS.

*************** Beginning of data ************************** PGM                                                                      DCLF       FILE(QGPL/SPOOLED) OPNID(SPOOL)                  DCLF       FILE(QGPL/DLTOLDSPLF) OPNID(DISPLAY)              DCL        VAR(&SPLF) TYPE(*CHAR) LEN(10)                            DCL        VAR(&SPOOLED) TYPE(*CHAR) LEN(132)                 DCL &USER *CHAR 10                                            DCL &JOBN *CHAR 10                                            DCL &JOB# *CHAR 10                                            DCL &SPL# *CHAR 10                                            DCL &SPLDT *CHAR 8                                            DCL VAR(&SPLNO) TYPE(*DEC) LEN(5 0)                           DCL &SPLD *CHAR 8                                             DCL        VAR(&SPOOLED) TYPE(*CHAR) LEN(132)                          DCL &USER *CHAR 10                                                     DCL &JOBN *CHAR 10                                                     DCL &JOB# *CHAR 10                                                     DCL &SPL# *CHAR 10                                                     DCL &SPLDT *CHAR 8                                                     DCL VAR(&SPLNO) TYPE(*DEC) LEN(5 0)                                    DCL &SPLD *CHAR 8                                                      DCL &COFF *CHAR 8                                                      SNDRCVF    OPNID(DISPLAY)                                              IF         COND(&DISPLAY_IN03 *EQ '1') THEN(GOTO +                                CMDLBL(EXIT))                                           OVRPRTF    FILE(QPRTSPLQ) MAXRCDS(300000) HOLD (*YES)                   WRKOUTQ    OUTQ(&DISPLAY_LIB/&DISPLAY_OUTQ) OUTPUT(*PRINT)              MONMSG     MSGID(CPF9999)                                            CRTPF      FILE(QTEMP/SPOOLED) RCDLEN(132) SIZE(*NOMAX)                           MONMSG     CPF0000                                                     CPYSPLF    FILE(QPRTSPLQ) TOFILE(QGPL/SPOOLED) +                                            SPLNBR(*LAST)                                              DLTSPLF    FILE(QPRTSPLQ) SPLNBR(*LAST)                               DLTOVR     QPRTSPLQ                                       LOOP:       RCVF       OPNID(SPOOL)                                             MONMSG     MSGID(CPF0864) EXEC(DO)                                    RMVMSG     PGMQ(*SAME) CLEAR(*ALL)                                    GOTO       CMDLBL(QUIT)                                               ENDDO                                                     QUIT:                                                                         CHGVAR     VAR(&SPLF) VALUE(%SST(&SPOOL_SPOOLED 2 10))             CHGVAR     VAR(&USER) VALUE(%SST(&SPOOL_SPOOLED 13 10))            CHGVAR     VAR(&JOBN) VALUE(%SST(&SPOOL_SPOOLED 84 10))            CHGVAR     VAR(&JOB#) VALUE(%SST(&SPOOL_SPOOLED 95 6))             CHGVAR     VAR(&SPL#) VALUE(%SST(&SPOOL_SPOOLED 75 4))             CHGVAR     VAR(&SPLDT) VALUE(%SST(&SPOOL_SPOOLED 102 8))                                                               /* SEE IF THE SPOOL FILE IS PAST EXPIRATION */                               IF         COND(&SPLF = '5722SS1  V') THEN(DO)                     GOTO       CMDLBL(LOOP)                                            ENDDO                                                              IF         COND(&SPLF = 'File     ') THEN(DO)                      GOTO       CMDLBL(LOOP)                                            ENDDO                                                              CVTDAT     DATE(&SPLDT) TOVAR(&SPLD) FROMFMT(*DMY) +               CVTDAT     DATE(&DISPLAY_CUTOFF) TOVAR(&COFF) FROMFMT(*DMY+                                   ) TOFMT(*YYMD) TOSEP(*NONE)                             IF         COND(&SPLD < &COFF) THEN(DO)                               CHGVAR     VAR(&SPLNO) VALUE(&SPL#)                                   DLTSPLF    FILE(&SPLF) JOB(&JOB#/&USER/&JOBN) +                                             SPLNBR(&SPLNO)                                             MONMSG     CPF0000                                                    GOTO       CMDLBL(LOOP)                                               ENDDO                                                      EXIT:                                                                ENDPGM                                                               

****************** End of data *************************

Through the Display File we are passing 3 Parameters i.e. LIBRARY NAME (Library where the User OUTQ was Created for example - QGPL or QUSRSYS), OUTPUT QUEUE (OUTQ Name of the User for example - OPRAVIB) and Date (Upto When The Spool Files Can Be Deleted for example - 28/10/09 - DD/MM/YY FORMAT).

When we run this program using the above mentioned parameters, Spool Files till 27/10/09 Night 00:00:00, will be deleted from User OPRAVIB's OUTQ.

This is the Current Process we are following. However using this Program at a time, we can delete Spool Files from a Single OUQ only.

What if I want to Delete All Spool Files of Multiple Users using a Generic Name i.e. instead of OPRAVIB, it should delete Spool Files of All Users Starting With OP and minusing the Libray Name Parameter mentioned in the Display File.


Haaider Ali

Software/Hardware used:
iSeries System i570, V5R4M0

Answer Wiki

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

This seems to be a common question.
Here is a link to the same basic question and it has great answers.

Discuss This Question: 2  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.
  • WoodEngineer
    Check out IBM's DLTOLDSPLF. I believe we found it in an IBM Redbook. It is very useful and can be easily enhanced. The important thing is that all the "heavy lifting" has already been done by IBM. There are a number of Google references to DLTOLDSPLF. By the way, the command allows deletion of all spool files for a given user. You could add a little code to limit to deletion to spool files with the leading characters of your choice.
    6,955 pointsBadges:
  • TomLiotta
    Use this link for the corrected code for DLTOLDSPLF. And review the entire descriptive text in that document. It includes mention of recent features added to i5/OS for aging spooled files. For many years, I've had the Age Spool Files Directory at my site for those who are beginning to investigate this kind of programming. It's pretty old itself now and needs to be modernized, but it can be useful as a learning tool -- which is why it was created. Tom
    125,585 pointsBadges:

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.

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


Share this item with your network: