As you are probably aware you as of V6R1 you can create a .PDF as output instead of a printout by using an override statement.
Sample code from above article.
This code allows you to create a pdf from an existing (after the report has been generated) SCS report (this will not work for an afp report). It is written entirely in CLLE and I am sure there are much better ways of doing the same.
To drive the above I've used a DTAQ.
Source mostly stolen from here: http://www.itjungle.com/fhg/fhg021104-story02.html
I used a type 1 dtaq with senderid
Jamie has posted a much nicer rpg version of processing the dtaq here:
http://www.code400.com/forum/showthr...tion?highlight=
To gracefully end the dtaq monitoring you can run the following:
I hope this helps someone else
GLS
< edit > the spool file must be in "RDY" status to create an entry on the DTAQ < / edit >
Sample code from above article.
Code:
[FONT=courier new]OVRPRTF FILE([I]testfile[/I]) DEVTYPE(*AFPDS) TOSTMF('/pdfdir/testfile.pdf') WSCST(*PDF)[/FONT]
Code:
[FONT=courier new]pgm parm(&prtname &jobname &username &jobno &splno &pdfname) [/FONT] [FONT=Courier New]/* 1. copy spool file to physical file */[/FONT] [FONT=courier new]/* 2. create directory to place the pdf */[/FONT] [FONT=courier new]/* 3. override print output to pdf in */[/FONT] [FONT=courier new]/* 4. email to requesting user */[/FONT] [FONT=courier new]/* 5. Clean up */[/FONT] [FONT=courier new]dcl &prtname *char 10 [/FONT] [FONT=courier new]dcl &jobname *char 10 [/FONT] [FONT=courier new]dcl &username *char 10 [/FONT] [FONT=courier new]dcl &jobno *char 6 [/FONT] [FONT=courier new]dcl &splno *char 6 [/FONT] [FONT=courier new]dcl &direntry *char 40 [/FONT] [FONT=courier new]dcl &pdfname *char 15 [/FONT] [FONT=courier new] /* topdf is a blank flat file 199 bytes */ [/FONT] [FONT=courier new]CPYF FROMFILE(QS36F/TOPDF) TOFILE(QTEMP/TOPDF) + [/FONT] [FONT=courier new] MBROPT(*REPLACE) CRTFILE(*YES) [/FONT] [FONT=courier new]Monmsg cpf0000 [/FONT] [FONT=courier new]ClrPfm Qtemp/ToPdf [/FONT] [FONT=courier new] /* copy spool file to physical file use *fcfc print ctl */ [/FONT] [FONT=courier new]CPYSPLF FILE(&PRTNAME) TOFILE(QTEMP/TOPDF) + [/FONT] [FONT=courier new] JOB(&JOBNO/&USERNAME/&JOBNAME) + [/FONT] [FONT=courier new] SPLNBR(&SPLNO) MBROPT(*REPLACE) + [/FONT] [FONT=courier new] CTLCHAR(*FCFC) [/FONT] [FONT=courier new] /* &direntry is where the pdf will be placed */ [/FONT] [FONT=courier new]CHGVAR VAR(&DIRENTRY) VALUE('/usrfls/out/' *CAT &username) [/FONT] [FONT=courier new]MD DIR(&direntry) DTAAUT(*RWX) + [/FONT] [FONT=courier new]OBJAUT(*ALL) [/FONT] [FONT=courier new]monmsg cpf0000 [/FONT] [FONT=Courier New] /* set up pdf file name */[/FONT] [FONT=courier new]Chgvar Var(&direntry) value(&direntry *Tcat '/' *Tcat + [/FONT] [FONT=courier new] &pdfname) [/FONT] [FONT=courier new]OVRPRTF FILE(*PRTF) DEVTYPE(*AFPDS) CTLCHAR(*FCFC) + [/FONT] [FONT=courier new] tostmf(&direntry) wscst(*pdf) [/FONT] [FONT=courier new]CPYF FROMFILE(QTEMP/topdf) TOFILE(QSYSPRT) [/FONT] [FONT=courier new] DLTOVR FILE(*PRTF)[/FONT] [FONT=courier new] /* This is my version of Email the PDF to Requesting User..you will need + [/FONT] [FONT=courier new] to substitute your own version */[/FONT] [FONT=courier new]EMATTACH2 SUBJ('PDF Spool File') FILENM(&PDFNAME) +[/FONT] [FONT=courier new] LMSG('PDF Spool file') USR(&USERNAME) [/FONT] [FONT=courier new] /* Move the live spool file to a backup output queue */[/FONT] [FONT=courier new]CHGSPLFA FILE(&PRTNAME) + [/FONT] [FONT=courier new] JOB(&JOBNO/&USERNAME/&JOBNAME) +[/FONT] [FONT=courier new] SPLNBR(&SPLNO) OUTQ(PDFOUTQBU) [/FONT] [FONT=courier new] /* Clean Up...Delete the PDF just generated */[/FONT] [FONT=courier new]RMVLNK &DIRENTRY [/FONT] [FONT=courier new] /* Delete work file */[/FONT] [FONT=courier new]Dltf Qtemp/ToPdf [/FONT] [FONT=courier new]endpgm [/FONT]
Source mostly stolen from here: http://www.itjungle.com/fhg/fhg021104-story02.html
Code:
PGM DCL VAR(&DQNAME) TYPE(*CHAR) LEN(10) VALUE('PDFOUTQDQ') DCL VAR(&DQLIB) TYPE(*CHAR) LEN(10) VALUE('QUSRSYS') DCL VAR(&DTALEN) TYPE(*DEC) LEN(5 0) VALUE(222) DCL VAR(&DATA) TYPE(*CHAR) LEN(222) DCL VAR(&WAIT) TYPE(*DEC) LEN(5 0) VALUE(-1) DCL VAR(&JOBNAME) TYPE(*CHAR) LEN(26) DCL VAR(&SPLFNAME) TYPE(*CHAR) LEN(10) DCL VAR(&SPLFNBR) TYPE(*CHAR) LEN(4) DCL VAR(&SPLNBR) TYPE(*DEC) LEN(10 0) DCL VAR(&SPLNBRA) TYPE(*CHAR) LEN(6) DCL VAR(&JOBNAM) TYPE(*CHAR) LEN(10) DCL VAR(&JOBUSR) TYPE(*CHAR) LEN(10) DCL VAR(&JOBNBR) TYPE(*CHAR) LEN(6) /*=================================================================*/ /* Process Next Spooled File From Data Queue Entry. */ READNEXT: CALL PGM(QRCVDTAQ) PARM(&DQNAME &DQLIB &DTALEN + &DATA &WAIT) IF COND(%SST(&DATA 1 10) *NE '*SPOOL ') + THEN(GOTO CMDLBL(ENDPGM)) CHGVAR VAR(&SPLFNAME) VALUE(%SST(&DATA 39 10)) CHGVAR VAR(&JOBNAME) VALUE(%SST(&DATA 13 26)) CHGVAR VAR(&SPLFNBR) VALUE(%SST(&DATA 49 4)) CHGVAR VAR(&JOBNAM) VALUE(%SST(&JOBNAME 1 10)) CHGVAR VAR(&JOBUSR) VALUE(%SST(&JOBNAME 11 10)) CHGVAR VAR(&JOBNBR) VALUE(%SST(&JOBNAME 21 6)) CHGVAR VAR(&SPLNBR) VALUE(%BIN(&SPLFNBR)) CHGVAR VAR(&SPLNBRA) VALUE(&SPLNBR) CALL PDFMECL PARM(&SPLFNAME &JOBNAM &JOBUSR + &JOBNBR &SPLNBRA 'SPOOLFILE.PDF') GoTo CmdLbl(READNEXT) ENDPGM: ENDPGM
Code:
CRTDTAQ DTAQ(QUSRSYS/PDFOUTQDQ) MAXLEN(256) SENDERID(*YES) AUTORCL(*YES)
http://www.code400.com/forum/showthr...tion?highlight=
To gracefully end the dtaq monitoring you can run the following:
Code:
PGM DCL VAR(&DQNAME) TYPE(*CHAR) LEN(10) VALUE('PDFOUTQDQ') DCL VAR(&DQLIB) TYPE(*CHAR) LEN(10) VALUE('QUSRSYS') DCL VAR(&DTALEN) TYPE(*DEC) LEN(5 0) VALUE(222) DCL VAR(&DATA) TYPE(*CHAR) LEN(222) VALUE(' ') /*===========================================================*/ /* Send "END" entries to Data Queues. */ /*===========================================================*/ CALL PGM(QSNDDTAQ) PARM(&DQNAME &DQLIB + &DTALEN &DATA) ENDPGM: ENDPGM
GLS
< edit > the spool file must be in "RDY" status to create an entry on the DTAQ < / edit >
Comment