Many CL commands produce some kind of information output that can often be routed to the display or to the printer by choosing between OUTPUT(*) or OUTPUT(*PRINT). Comparatively few commands offer a third option, OUTPUT(*OUTFILE) to send the output to a database file directly.
If the command you want to run doesn't offer outfile support, such as the Display Library (DSPLIB) command, there's a rather clumsy way to circumvent it and obtain the output in a database file. It involves the following steps:
1. Override the printer file used by the command with HOLD(*YES).
2. Run the command, specifying OUTPUT(*PRINT).
3. Copy the spool file to the database file.
4. Delete the spool file from the output queue.
5. Delete the override to the printer file.
For example, to capture the printed output of DSPLIB to database file SPLF132, you would code your CL program as shown in 1a. It requires five commands. Omit one of them and your CL program may blow up.
For example, to capture the printed output of DSPLIB to database file SPLF132, you would code your CL program as shown in Figure 1a. It requires five commands. Omit one of them and your CL program may blow up.
I created the Convert Print to Physical File (CVTPRTPF) command to simplify this kind of process. Compare 1a with 1b, which makes use of the CVTPRTPF command. One command takes care of everything.
I created the Convert Print to Physical File (CVTPRTPF) command to simplify this kind of process. Compare Figure 1a with Figure 1b, which makes use of the CVTPRTPF command. One command takes care of everything.
The CVTPRTPF command (2a) has four parameters. The first parameter, CMD, lets you enter the command you want to execute--the command that produces the output, like DSPLIB in our example. Parameter PRTF requires the name of the printer file used by the command. Parameter TOFILE lets you enter the qualified name of the physical file to receive the converted information, and parameter MBROPT where you enter the name of the member to receive the data (defaults to *FIRST) and whether to add or replace records within the member (the default is *REPLACE).
The CVTPRTPF command (Figure 2a) has four parameters. The first parameter, CMD, lets you enter the command you want to execute--the command that produces the output, like DSPLIB in our example. Parameter PRTF requires the name of the printer file used by the command. Parameter TOFILE lets you enter the qualified name of the physical file to receive the converted information, and parameter MBROPT where you enter the name of the member to receive the data (defaults to *FIRST) and whether to add or replace records within the member (the default is *REPLACE).
CVTPRTPF uses the CL program PRT004CL (2b) to reproduce the manual steps. CVTPRTPF takes the pain out of retrieving printed information. I'm sure that you'll begin using OUTPUT(*PRINT) some more when you realize its potential.
CVTPRTPF uses the CL program PRT004CL (Figure 2b) to reproduce the manual steps. CVTPRTPF takes the pain out of retrieving printed information. I'm sure that you'll begin using OUTPUT(*PRINT) some more when you realize its potential.
TechTalk: Using OUTPUT (*PRINT)
Figure 1A Capturing output manually
Figure 1a: Capturing Output Manually OVRPRTF FILE(QPDSPLIB) HOLD(*YES) DSPLIB LIB(QGPL) OUTPUT(*PRINT) CPYSPLF FILE(QPDSPLIB) TOFILE(SPLF132) JOB(*) + SPLNBR(*LAST) TOMBR(*FIRST) MBROPT(*REPLACE) DLTSPLF FILE(QPDSPLIB) JOB(*) SPLNBR(*LAST) + SELECT(*CURRENT) DLTOVR FILE(QPDSPLIB)
TechTalk: Using OUTPUT (*PRINT)
Figure 1B Capturing output with CVTPRTPF
Figure 1b: Capturing Output With CVTPRTPF CVTPRTPF CMD(DSPLIB LIB(QGPL) OUTPUT(*PRINT)) + PRTF(QPDSPLIB) TOFILE(SPLF132) + MBROPT(*FIRST *REPLACE)
TechTalk: Using OUTPUT (*PRINT)
Figure 2A Command CVTPRTPF
CVTPRTPF: CMD PROMPT('Convert Print to Physical File') PARM KWD(CMD) TYPE(*CMDSTR) LEN(3000) MIN(1) + PROMPT('Command to produce output') PARM KWD(PRTF) TYPE(*NAME) LEN(10) MIN(1) + PROMPT('Printer file name') PARM KWD(TOFILE) TYPE(Q1) MIN(1) PROMPT('To + physical file') PARM KWD(MBROPT) TYPE(E1) PROMPT('Member options') Q1: QUAL TYPE(*NAME) LEN(10) MIN(1) QUAL TYPE(*NAME) LEN(10) DFT(*CURLIB) + SPCVAL((*CURLIB)) PROMPT('Library') E1: ELEM TYPE(*NAME) LEN(10) DFT(*FIRST) + SPCVAL((*FIRST)) PROMPT('Member to + receive output') ELEM TYPE(*CHAR) LEN(8) RSTD(*YES) DFT(*REPLACE) + VALUES(*REPLACE *ADD) PROMPT('Replace or + add records')
TechTalk: Using OUTPUT (*PRINT)
Figure 2B CL program PRT004CL
PRT004CL: + PGM PARM(&CMD &PRTF &QF &MEMBER) DCL VAR(&CMD) TYPE(*CHAR) LEN(3000) DCL VAR(&FILE) TYPE(*CHAR) LEN(10) DCL VAR(&LIB) TYPE(*CHAR) LEN(10) DCL VAR(&MBR) TYPE(*CHAR) LEN(10) DCL VAR(&MBROPT) TYPE(*CHAR) LEN(8) DCL VAR(&MEMBER) TYPE(*CHAR) LEN(20) DCL VAR(&PRTF) TYPE(*CHAR) LEN(10) DCL VAR(&QF) TYPE(*CHAR) LEN(20) CHGVAR VAR(&FILE) VALUE(%SST(&QF 1 10)) CHGVAR VAR(&LIB) VALUE(%SST(&QF 11 10)) CHGVAR VAR(&MBR) VALUE(%SST(&MEMBER 3 10)) CHGVAR VAR(&MBROPT) VALUE(%SST(&MEMBER 13 8)) CHKOBJ OBJ(&LIB/&FILE) OBJTYPE(*FILE) MONMSG MSGID(CPF9810) EXEC(DO) SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA('Library' *BCAT + 'not found') MSGTYPE(*ESCAPE) RETURN ENDDO MONMSG MSGID(CPF9801) EXEC(DO) CRTPF FILE(&LIB/&FILE) RCDLEN(512) ENDDO CHKOBJ OBJ(&LIB/&FILE) OBJTYPE(*FILE) MBR(&MBR) MONMSG MSGID(CPF9815) EXEC(DO) ADDPFM FILE(&LIB/&FILE) MBR(&MBR) ENDDO OVRPRTF FILE(&PRTF) HOLD(*YES) CALL PGM(QCMDEXC) PARM(&CMD 3000) MONMSG MSGID(CPF0000) EXEC(DO) FWDPGMMSG FROMPGMQ(PRT004CL) RETURN ENDDO CPYSPLF FILE(&PRTF) TOFILE(&LIB/&FILE) JOB(*) SPLNBR(*LAST) + TOMBR(&MBR) MBROPT(&MBROPT) DLTSPLF FILE(&PRTF) JOB(*) SPLNBR(*LAST) SELECT(*CURRENT) DLTOVR FILE(&PRTF) ENDPGM
LATEST COMMENTS
MC Press Online