Create a hot 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:

CRTDTAQ  DTAQ(QGPL/ZDTAQ1)

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                                           */
 /*****************************************************************************/
             PGM
             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(' ')
             CALL       PGM(QRCVDTAQ) PARM(ZDTAQ1 QGPL &FLDLEN &FIELD +
                          &WAIT)
 /* 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:                       */
 /* DLTSPLF FILE(&SPLNM) JOB(&JOBNBR/&USER/&JOBNM) SPLNBR(&SPLNBR)        */ 


             GOTO       CMDLBL(LOOP)
             ENDPGM
_
 

This was first published in March 2003

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.