One example: PRINTING A SPOOL ON BOTH SIDES OF THE PAPER
Follow the Steps:
1. Create a new DTAQ by the following command:
CRTDTAQ DTAQ(QGPL/ZDTAQ1) MAXLEN(64512)
2. Create a OUTQ with the following command:
CRTOUTQ OUTQ(QGPL/DUPLEX) DTAQ(QGPL/ZDTAQ1)
3. Compile the following CL program after making necessary modifications to it. (You probably need to change the out queue name in the last CL command CHGPLFA)
Note 1:
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.
Note 2:
You
may want to add the CALL to this program in the system startup program,
so that it gets executed automatically, after every IPL.
So, from now on, whenever you need to print the spool file on the both sides of a paper, just send the spool file to the OUTQ DUPLEX instead of the regular OUTQ (PRINT01 in this case). The output will appear on PRINT01 (your actual existing OUTQ) only.
To print regular one-sided spool files simply send the spool files to PRINT01 (your actual existing OUTQ).
Code
CL Program:
/**********************************************************************/
/* Author : Ravinder K. Pal
*/
/* Description : Print both sides of the paper (driver)
*/
/**********************************************************************/
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(&TNAME) TYPE(*CHAR) LEN(50)
DCL VAR(&FM) TYPE(*CHAR) LEN(32)
DCL VAR(&SNAME) TYPE(*CHAR) LEN(
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))
CHGSPLFA FILE(&SPLNM) JOB(&JOBNBR/&USER/&JOBNM) +
SPLNBR(&SPLNBR) DUPLEX(*YES)
MONMSG CPF0000
CHGSPLFA FILE(&SPLNM) JOB(&JOBNBR/&USER/&JOBNM) +
SPLNBR(&SPLNBR) OUTQ(PRINT01)
/* PRINT01 is used as an example. Instead of PRINT01, you will use the name
of an existing OUTQ */
GOTO CMDLBL(LOOP)
ENDPGM