Problem solve Get help with specific problems with your technologies, process and projects.

Create a hot OUTQ

Here's an OUTQ monitor program that monitors an OUTQ. The program knows exactly when any spool file appears in the OUTQ.

At times, we need to take some action based on the spool file availability in any OUTQ. I have created an OUTQ...

monitor program, which monitors a OUTQ and knows exactly when any spool file appears in the OUTQ. I'm using this program to be able to automatically e-mail the monthly sales spool files, as soon as they get created in the system. However, the functions of this program are not limited. You can use this program driver to do the following:

-In the development box, delete the spool files as soon as they get created to do housekeeping.

- Convert the spool files into HTML and PDF formats automatically.

- Distribute the spool files in different systems via SNDNETSPLF.

- Print the spool file to an IP printer, as soon as they get created via SNDTCPSPLF command.

The program needs to be running all the time in the system. The program doesn't take any CPU resource as it waits in DEQW status until a spool file comes in the OUTQ. It's worth giving it a try.

First Create a DATA QUEUE:


Create a new OUTQ or change the existing OUTQ to have Data Queue attached to it:

CHGOUTQ   OUTQ(outqueue name)   DTAQ(QGPL/ZDTAQ1)

CL Program: 
 /* Author      : Ravinder K. Pal                                           */
             DCL        VAR(&FLDLEN) TYPE(*DEC) LEN(5 0) VALUE(128)
             DCL        VAR(&FIELD) TYPE(*CHAR) LEN(128)

             DCL        VAR(&ERR) TYPE(*CHAR) LEN(50)
             DCL        VAR(&SPLNBR) TYPE(*DEC) LEN(9 0)
             DCL        VAR(&USER) TYPE(*CHAR) LEN(10)
             DCL        VAR(&SPLNM) TYPE(*CHAR) LEN(10)
             DCL        VAR(&JOBNM) TYPE(*CHAR) LEN(10)
             DCL        VAR(&JOBNBR) TYPE(*CHAR) LEN(6)
             DCL        VAR(&ERR) TYPE(*CHAR) LEN(50)
             DCL        VAR(&ERR) TYPE(*CHAR) LEN(50)
             DCL        VAR(&TNAME) TYPE(*CHAR) LEN(50)
             DCL        VAR(&FM) TYPE(*CHAR) LEN(32)
             DCL        VAR(&SNAME) TYPE(*CHAR) LEN(8)
             DCL        VAR(&WAIT) TYPE(*DEC) LEN(5 0)
 LOOP:       CHGVAR     VAR(&WAIT) VALUE(-1) /* wait for new entry +
                          on the data queue */
             CHGVAR     VAR(&FIELD) VALUE(' ')
 /* Get the Spool file number for the spool file  */
             CHGVAR     VAR(&SPLNBR) VALUE(%BIN(&FIELD 49 4))
 /* Get the Job name for the spool file   */
             CHGVAR     VAR(&JOBNM) VALUE(%SST(&FIELD 13 10))
 /* Get the user ID for the spool file   */
             CHGVAR     VAR(&USER) VALUE(%SST(&FIELD 23 10))
 /* Get the Job Number for the spool file  */
             CHGVAR     VAR(&JOBNBR) VALUE(%SST(&FIELD 33 6))
 /* Get the spool file name */
             CHGVAR     VAR(&SPLNM) VALUE(%SST(&FIELD 39 10))
 /* write your own code depending upon the function you want to perform.. */
 /* for deleting the spool file type the following:                       */

             GOTO       CMDLBL(LOOP)

Dig Deeper on iSeries CL programming

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.