On the S/36, there was the COPYPRT procedure, which allowed users to copy spool files to disk files and save them on a backup media for archival purposes. Later, the user could restore the archived files and recreate the original spooled file. As yet, IBM has not developed an AS/400 utility to accomplish this; however, the tools to create this utility are present. Let's explore the Save Spool File (SAVSPLF) and the Restore Spool File (RSTSPLF) commands.
SAVSPLF takes the spooled files and creates two disk files that can be saved and restored. One file contains the data from the spool file, the other contains the spool file attributes. Just as the song says, "I'll get by with a little help from my friends," so to, SAVSPLF needs some help from the tools found in the QUSRTOOL library: CVTWRKSPLF (Convert WRKSPLF) and RTVSPLFA (Retrieve Spool File Attributes), along with one small modification to the CVTWRKSPLF user tool. RSTSPLF takes the data created from SAVSPLF off of the specified device and recreates the spooled file.
The SAVSPLF Command
Let's take a closer look at the SAVSPLF command, the Command Processing Program (CPP), and related programs. The SAVSPLF command first asks for the device on which to save the data. This parameter is required, and the CPP ensures that a valid device name is entered.
Parameter USER defaults to *CURRENT, which means that the current user's spool files will be saved. It also accepts *ALL, which archives all spool files (a user name can be entered for this parameter).
Other selection parameters are: the print device, form type and user data parameters. You can use any combination of these, or leave the default to *ALL.
If you're saving the spool files on tape, be sure to indicate what you want the tape drive to do when the Save is done. Use the ENDOPT parameter for this purpose; it defaults to *LEAVE, but it can be changed to *REWIND or *UNLOAD.
Lastly, the OUTLIB parameter enables the user to select a particular library in which to retain the spool data and attributes. I prefer QTEMP because of its automatic housecleaning capabilities, but you may use any valid library.
The RSTSPLF Command
The RSTSPLF command and related programs are not quite as complicated as SAVSPLF. The RSTSPLF command has only three parameters: the device which was used for the save, the name of the spooled file and the end of tape option, which defaults to *LEAVE. Again, the device is required, and the name may be an individual spool entry (Snnnnnnnnn where n is the sequential number assigned in SPLF001CL), or *ALL, which restores all spool entries.
Creating the Utility
To create the SAVSPLF and RSTSPLF commands, follow these steps:
1. Create user tools CVTWRKSPLF and RTVSPLFA, if you haven't already:
CRTTAATOOL TOOL(CVTWRKSPLF) CRTTAATOOL TOOL(RTVSPLFA)
2. Create printer file SPLF002P1. "xxx" is the name of the library where you want to place all the programming support for SAVSPLF and RSTSPLF:
CRTPRTF FILE(xxx/SPLF002P1) + PAGESIZE(255 378) + CTLCHAR(*FCFC) + MAXRCDS(*NOMAX)
3. Enter and compile each source member, in the same order given by Figures 1 through 3c.
How SAVSPPLF Works
SPLF001CL is the CPP for the SAVSPLF command. Declare one file, WRKSPLFP, which is the default name from the CVTWRKSPLF user tool. CVTWRKSPLF takes the static information from the WRKSPLF display and creates an externally described file with this static data. The DDS for WRKSPLFP is located in QUSRTOOL/QATTDDS, and the member is named TAASPLHP.
The program then checks for the validity of the Save device. Next, a file called Save Spool File Physical File (SAVSPLFPF) is created to hold the actual spool file data. SAVSPLFPF has a record length of 273, with no limit on the number of members.
Next, an IBM-supplied tool CVTWRKSPLF (with a small modification) is used. If you look closely at the command, you'll see a lot of similarity in the parameters of CVTWRKSPLF and SAVSPLF commands. The similarity is intentional since you need almost the identical information to process the spool files into disk files.
You'll be making modifications to CVTWRKSPLF. When CVTWRKSPLF creates the record, the spooled file number (SFFNBR in the DDS specifications) is a five- character, alphanumeric field. For each job name, user and job number, the AS/400 assigns a unique number to distinguish a print job from a second print job with the same job name, user and job number. This is called the spooled file number, and is found on View 3 of WRKSPLF, View 2 of WRKOUTQ under the heading "File Nbr."
As supplied by IBM, CVTWRKSPLF writes this as the rightmost character of the five-character field. RTVSPLFA requires this field to be in the leftmost characters of the field.
The name of the RPG program we'll change is TAASPLHR. In the code for TAASPLHR, all of the modifications have been noted with a ===> in the first four positions of each line. First, set up a four character by one byte array for the field (SFN). Then, after the field (SFFNBR) is initialized, exit to a subroutine that moves the four-byte file number to the array SFN, then does a cycle of moves until the first byte of the array is not equal to blanks. Finally, the array is moved back to the original field name.
Next, the file Save Spool File Attributes (SAVSPLFA) is created. This externally described file will hold all of the attributes of the various spool entries. In order to avoid hard-coding library names, use the RTVOBJD and CRTDUPOBJ command to create file SAVSPLFA.
Now the program reads the first record from WRKSPLFP. If end-of-file is detected (CPF0864), the loop is exited. The CL variable &NBR is a nine- position, zero decimal numeric variable. It is used to place a unique designator on each spooled file. It is increased by one on each successive read of WRKSPLFP and concatenated with the letter "S." This field becomes the member name in the SAVSPLFPF file which contains the spooled data, and the key of the SAVSPLFA file which contains the attributes of the member in SAVSPLFPF.
With all the necessary fields ready, use the CPYSPLF command to copy the spooled file into the SAVSPLFPF file, specifying the member name, the option to add the member and a forms control character of First Character Forms Control (*FCFC). The forms control character is a one-byte character that directs the printed output. A complete description of the forms control character is found in the AS/400 Guide to Printing (SC21-8194). If you are on V1R3, look at page 3-24. If you're on V2R1, look at page 3-33. The forms control character resides in the first position of the data.
Next, the attributes of each spooled file are retrieved using some of the same CL variables.
CRTTAATOOL RTVSPLFA
This user tool returns the spool file attributes to CL variables. We the use those variables and call SPLF001RG, which simply passes the parameters to an RPG program, and writes them into the file, SAVSPLFA.
After all records have been read, the program saves the objects SAVSPLFA and SAVSPLFPF on the device of your choice. SAVSPLF generates one report (which is placed in your default output queue), listing the spool files that were saved. Keep this report with the magnetic media; it will serve as a directory of the reports that were saved.
How RSTSPLF Works
Program SPLF002CL restores the two files that were created by the SAVSPLF command. It first checks to make sure the device name is valid and then restores the two files with the RSTOBJ command, and calls program SPLF002CLA.
Program SPLF002CLA has &SPLF passed from SPLF002CL. This is the name of the individual spool file to be restored, or *ALL. If you requested to restore a specific spool file by name, SPLF002CLA reads its corresponding record in SAVSPLFA by key; otherwise, it reads all records sequentially.
SPLF002CLA then issues a massive override to printer file SPLF002P1, which is generic in nature, using the data read from file SAVSPLFA. As a result, printer file SPLF002P1 can duplicate, almost exactly, the original output that was saved with SAVSPLF. The spooled file data is copied from SAVSPLFPF to the printer file, reproducing the original report. Read another record if *ALL spool files were selected for restore, and the cycle repeats itself until the end of file is reached.
Observations
First, SAVSPLF uses two tools from QUSRTOOL: CVTWRKSPLF and RTVSPLFA. SAVSPLF, as coded in this article, will work until IBM changes or discontinues either tool. In particular, RTVSPLFA is a likely candidate to become a standard QSYS command in the future. This has already happened to several QUSRTOOL tools.
Second, CVTWRKSPLF had to be modified. Next time you upgrade to a new release of OS/400, the source code may revert back to its original form. You should keep a copy of the modified source member in another source file and library.
Third, RSTSPLF will not restore the spool file to its original output queue, but to the default output queue of the user who runs RSTSPLF. This is due to a limitation of the RTVSPLFA tool--it does not retrieve the name of the original output queue or its library.
Saving and Restoring Spool Files
Figure 1 Modification to TAASPLHR
Figure 1: Modification to TAASPLHR *...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ... E ARA 132 1 ===> E SFN 4 1 ... C MOVEAARA,101 SFFNBR ===> C EXSR SFNBR C MOVEAARA,106 SFJNAM ... C MOVE SAVE4 SAVE6 C ENDSR ===> C SFNBR BEGSR ===> C SFNBR1 TAG ===> C CLEARSFN ===> C MOVEASFFNBR SFN ===> C SFN,1 IFEQ *BLANK ===> C MOVE SFN,2 SFN,1 ===> C MOVE SFN,3 SFN,2 ===> C MOVE SFN,4 SFN,3 ===> C CLEARSFN,4 ===> C MOVEASFN SFFNBR ===> C GOTO SFNBR1 ===> C END ===> C ENDSR *...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 To compile: CRTRPGPGM PGM(TAATOOL/TAASPLHR) + SRCFILE(QUSRTOOL/QATTRPG)
Saving and Restoring Spool Files
Figure 2A Command SAVSPLF
SAVSPLF: CMD PROMPT('Save Spool Files') PARM KWD(DEV) TYPE(*SNAME) LEN(10) MIN(1) + PROMPT('Save device') PARM KWD(USER) TYPE(*NAME) LEN(10) DFT(*CURRENT) + SPCVAL((*CURRENT) (*ALL)) EXPR(*YES) + PROMPT('User name') PARM KWD(PRTDEV) TYPE(*NAME) LEN(10) DFT(*ALL) + SPCVAL((*ALL) (*OUTQ)) EXPR(*YES) + PROMPT('Print device') PARM KWD(FORMTYPE) TYPE(*CHAR) LEN(10) DFT(*ALL) + SPCVAL((*ALL) (*STD)) EXPR(*YES) + PROMPT('Form type') PARM KWD(USRDTA) TYPE(*CHAR) LEN(10) DFT(*ALL) + SPCVAL((*ALL)) EXPR(*YES) PROMPT('User data') PARM KWD(ENDOPT) TYPE(*CHAR) LEN(7) RSTD(*YES) + DFT(*LEAVE) VALUES(*LEAVE *REWIND + *UNLOAD) PROMPT('End of tape option') PARM KWD(OUTLIB) TYPE(*NAME) LEN(10) DFT(QTEMP) + EXPR(*YES) PROMPT('Library for SAVSPLF file')
Saving and Restoring Spool Files
Figure 2B CL program SPLF001CL
SPLF001CL: + PGM PARM(&SAVDEV &USER &PRTDEV &FORMTYPE &USRDTA &ENDOPT &OUTLIB) DCL VAR(&ALIGN) TYPE(*CHAR) LEN(4) DCL VAR(&CPI) TYPE(*CHAR) LEN(2) DCL VAR(&CPYS) TYPE(*CHAR) LEN(3) DCL VAR(&DETYP) TYPE(*CHAR) LEN(10) DCL VAR(&DKTDEV) TYPE(*LGL) LEN(1) DCL VAR(&DRAWR) TYPE(*CHAR) LEN(1) DCL VAR(&ENDOPT) TYPE(*CHAR) LEN(7) DCL VAR(&FLSEP) TYPE(*CHAR) LEN(1) DCL VAR(&FMFED) TYPE(*CHAR) LEN(8) DCL VAR(&FOLD) TYPE(*CHAR) LEN(4) DCL VAR(&FONT) TYPE(*CHAR) LEN(5) DCL VAR(&FORMTYPE) TYPE(*CHAR) LEN(10) DCL VAR(&FRMTP) TYPE(*CHAR) LEN(10) DCL VAR(&HOLD) TYPE(*CHAR) LEN(4) DCL VAR(&JOBTYPE) TYPE(*CHAR) LEN(1) DCL VAR(&JSTFY) TYPE(*CHAR) LEN(3) DCL VAR(&LPI) TYPE(*CHAR) LEN(1) DCL VAR(&MBR) TYPE(*CHAR) LEN(10) DCL VAR(&MSG) TYPE(*CHAR) LEN(80) DCL VAR(&MXRCD) TYPE(*CHAR) LEN(10) DCL VAR(&NBR) TYPE(*DEC) LEN(9 0) DCL VAR(&NBRA) TYPE(*CHAR) LEN(9) DCL VAR(&OUTLIB) TYPE(*CHAR) LEN(10) DCL VAR(&OUTPY) TYPE(*CHAR) LEN(1) DCL VAR(&OVRFL) TYPE(*CHAR) LEN(3) DCL VAR(&PGLEN) TYPE(*CHAR) LEN(3) DCL VAR(&PGROT) TYPE(*CHAR) LEN(5) DCL VAR(&PGWDT) TYPE(*CHAR) LEN(3) DCL VAR(&PRQLT) TYPE(*CHAR) LEN(6) DCL VAR(&PRTDEV) TYPE(*CHAR) LEN(10) DCL VAR(&RPUNP) TYPE(*CHAR) LEN(4) DCL VAR(&RTNLIB) TYPE(*CHAR) LEN(10) DCL VAR(&SAVDEV) TYPE(*CHAR) LEN(10) DCL VAR(&SAVF) TYPE(*CHAR) LEN(4) DCL VAR(&SCHED) TYPE(*CHAR) LEN(8) DCL VAR(&SFFNBR#) TYPE(*DEC) LEN(4 0) DCL VAR(&TAPDEV) TYPE(*LGL) LEN(1) DCL VAR(&USER) TYPE(*CHAR) LEN(10) DCL VAR(&USRDTA) TYPE(*CHAR) LEN(10) DCLF FILE(WRKSPLFP) RTVJOBA TYPE(&JOBTYPE) /* Validate device name */ CHKOBJ OBJ(&SAVDEV) OBJTYPE(*DEVD) MONMSG MSGID(CPF9801) EXEC(DO) CHGVAR VAR(&MSG) VALUE('Save device' *BCAT &SAVDEV *BCAT + 'does not exist') GOTO CMDLBL(ERRMSG) ENDDO /* Check that existing device is diskette or tape */ CHGVAR VAR(&DKTDEV) VALUE('1') CHGVAR VAR(&TAPDEV) VALUE('1') CHGDEVDKT DEVD(&SAVDEV) TEXT(*SAME) MONMSG MSGID(CPF0000) EXEC(CHGVAR VAR(&DKTDEV) VALUE('0')) CHGDEVTAP DEVD(&SAVDEV) TEXT(*SAME) MONMSG MSGID(CPF0000) EXEC(CHGVAR VAR(&TAPDEV) VALUE('0')) IF COND(*NOT &DKTDEV *AND *NOT &TAPDEV) THEN(DO) CHGVAR VAR(&MSG) VALUE('Device' *BCAT &SAVDEV *BCAT 'is not a + diskette or a tape device') GOTO CMDLBL(ERRMSG) ENDDO /* Create spool identification file */ TAATOOL/CVTWRKSPLF USER(&USER) PRTDEV(&PRTDEV) + FORMTYPE(&FORMTYPE) USRDTA(&USRDTA) OUTLIB(&OUTLIB) + OUTMBR(WRKSPLFP) MONMSG MSGID(CPF9898) EXEC(DO) CHGVAR VAR(&MSG) VALUE('No spool files meet selection criteria') GOTO CMDLBL(ERRMSG) ENDDO OVRPRTF FILE(QPRTSPLF) PAGESIZE(*N 132) WRKSPLF SELECT(&USER &PRTDEV &FORMTYPE &USRDTA) OUTPUT(*PRINT) DLTOVR FILE(QPRTSPLF) /* Create physical file to copy spool files to */ DLTF FILE(&OUTLIB/SAVSPLFPF) MONMSG MSGID(CPF0000) CRTPF FILE(&OUTLIB/SAVSPLFPF) RCDLEN(273) MBR(*NONE) + MAXMBRS(*NOMAX) SIZE(*NOMAX) /* Create attributes physical file */ DLTF FILE(&OUTLIB/SAVSPLFA) MONMSG MSGID(CPF0000) RTVOBJD OBJ(SAVSPLFA) OBJTYPE(*FILE) RTNLIB(&RTNLIB) CRTDUPOBJ OBJ(SAVSPLFA) FROMLIB(&RTNLIB) OBJTYPE(*FILE) + TOLIB(&OUTLIB) NEWOBJ(*OBJ) DATA(*NO) ADDPFM FILE(&OUTLIB/SAVSPLFA) MBR(SAVSPLFA) MONMSG MSGID(CPF0000) /* Read record from WRKSPLFP */ OVRDBF FILE(WRKSPLFP) TOFILE(&OUTLIB/WRKSPLFP) RCVF: + RCVF MONMSG MSGID(CPF0864) EXEC(GOTO CMDLBL(ENDRCV)) /* Create numeric portion of member name */ CHGVAR VAR(&NBR) VALUE(&NBR + 1) CHGVAR VAR(&NBRA) VALUE(&NBR) /* Add member to SAVSPLFPF */ CHGVAR VAR(&MBR) VALUE('S' *CAT &NBRA) ADDPFM FILE(&OUTLIB/SAVSPLFPF) MBR(&MBR) CHGVAR VAR(&SFFNBR#) VALUE(&SFFNBR) /* Copy spool file to specified member */ CPYSPLF FILE(&SFFILE) TOFILE(&OUTLIB/SAVSPLFPF) + JOB(&SFJNBR/&SFUSER/&SFJNAM) SPLNBR(&SFFNBR#) TOMBR(&MBR) + MBROPT(*ADD) CTLCHAR(*FCFC) /* Retrieve spool file attributes and write to SAVSPLFA */ TAATOOL/RTVSPLFA SPLF(&SFFILE) JOB(&SFJNBR/&SFUSER/&SFJNAM) + SPLNBR(&SFFNBR) FORMTYPE(&FRMTP) OUTPTY(&OUTPY) COPIES(&CPYS) + MAXRCDS(&MXRCD) FILESEP(&FLSEP) SCHEDULE(&SCHED) HOLD(&HOLD) + SAVE(&SAVF) DEVTYPE(&DETYP) PAGLEN(&PGLEN) PAGWDT(&PGWDT) + LPI(&LPI) CPI(&CPI) OVRFLW(&OVRFL) FOLD(&FOLD) + RPLUNPRT(&RPUNP) ALIGN(&ALIGN) PRTQLTY(&PRQLT) + FORMFEED(&FMFED) DRAWER(&DRAWR) FONT(&FONT) PAGRTT(&PGROT) + JUSTIFY(&JSTFY) OVRDBF FILE(SAVSPLFA) TOFILE(&OUTLIB/SAVSPLFA) CALL PGM(SPLF001RG) PARM(&MBR &FRMTP &OUTPY &CPYS &MXRCD &FLSEP + &SCHED &HOLD &SAVF &DETYP &PGLEN &PGWDT &LPI &CPI &OVRFL + &FOLD &RPUNP &ALIGN &PRQLT &FMFED &DRAWR &FONT &PGROT &JSTFY + &SFFILE) GOTO CMDLBL(RCVF) /* Save files to device */ ENDRCV: + SAVOBJ OBJ(SAVSPLFA) LIB(&OUTLIB) DEV(&SAVDEV) OBJTYPE(*FILE) + ENDOPT(*LEAVE) SAVOBJ OBJ(SAVSPLFPF) LIB(&OUTLIB) DEV(&SAVDEV) OBJTYPE(*FILE) + ENDOPT(&ENDOPT) GOTO CMDLBL(ENDPGM) /* Send error message */ ERRMSG: + SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA(&MSG) MSGTYPE(*DIAG) SNDPGMMSG MSGID(CPF0002) MSGF(QCPFMSG) MSGTYPE(*ESCAPE) /* End program */ ENDPGM: + ENDPGM
Saving and Restoring Spool Files
Figure 2C Physical file SAVSPLFA
A R SSF001 A #MBR 10 TEXT('SPOOL FILE MEMBER NAME') A #FRMTP 10 TEXT('FORM TYPE') A #OUTPY 1 TEXT('OUTPUT PRIORITY') A #CPYS 3 TEXT('COPIES') A #MXRCD 10 TEXT('MAXIMUM RECORDS') A #FLSEP 1 TEXT('FILE SEPARATORS') A #SCHED 8 TEXT('SCHEDULE') A #HOLD 4 TEXT('HOLD SPOOL ENTRY') A #SAVF 4 TEXT('SAVE SPOOL AFTER OUTPUT') A #DETYP 10 TEXT('DEVICE TYPE') A #PGLEN 3 TEXT('PAGE LENGTH') A #PGWDT 3 TEXT('PAGE WIDTH') A #LPI 1 TEXT('LINES PER INCH') A #CPI 2 TEXT('CHARACTERS PER INCH') A #OVRFL 3 TEXT('OVERFLOW LINE') A #FOLD 4 TEXT('FOLD PRINT LINE') A #RPUNP 4 TEXT('REPLACE UNPRINTABLE CHARS') A #ALIGN 4 TEXT('ALIGNMENT LINE') A #PRQLT 6 TEXT('PRINT QUALITY') A #FMFED 8 TEXT('FORM FEED') A #DRAWR 1 TEXT('DRAWER') A #FONT 5 TEXT('FONT') A #PGROT 5 TEXT('PAGE ROTATION') A #JSTFY 3 TEXT('JUSTIFICATION') A #SPNAM 10 TEXT('SPOOL FILE NAME') A K #MBR
Saving and Restoring Spool Files
Figure 2D RPG program SPLF001RG
FSAVSPLFAO E K DISK A C *ENTRY PLIST C PARM #MBR 10 C PARM #FRMTP 10 C PARM #OUTPY 1 C PARM #CPYS 3 C PARM #MXRCD 10 C PARM #FLSEP 1 C PARM #SCHED 8 C PARM #HOLD 4 C PARM #SAVF 4 C PARM #DETYP 10 C PARM #PGLEN 3 C PARM #PGWDT 3 C PARM #LPI 1 C PARM #CPI 2 C PARM #OVRFL 3 C PARM #FOLD 4 C PARM #RPUNP 4 C PARM #ALIGN 4 C PARM #PRQLT 6 C PARM #FMFED 8 C PARM #DRAWR 1 C PARM #FONT 5 C PARM #PGROT 5 C PARM #JSTFY 3 C PARM #SPNAM 10 C WRITESSF001 C MOVE '1' *INLR
Saving and Restoring Spool Files
Figure 3A Command RSTSPLF
RSTSPLF: CMD PROMPT('Restore Spool Files') PARM KWD(DEV) TYPE(*SNAME) LEN(10) MIN(1) + PROMPT('Device name') PARM KWD(SPLF) TYPE(*NAME) LEN(10) DFT(*ALL) + SPCVAL((*ALL)) PROMPT('Spool file name') PARM KWD(ENDOPT) TYPE(*CHAR) LEN(7) RSTD(*YES) + DFT(*LEAVE) VALUES(*LEAVE *REWIND + *UNLOAD) PROMPT('End of tape option')
Saving and Restoring Spool Files
Figure 3B CL program SPLF002CL
SPLF002CL: + PGM PARM(&SAVDEV &SPLF &ENDOPT) DCL VAR(&SAVDEV) TYPE(*CHAR) LEN(10) DCL VAR(&SPLF) TYPE(*CHAR) LEN(10) DCL VAR(&MSG) TYPE(*CHAR) LEN(80) DCL VAR(&ENDOPT) TYPE(*CHAR) LEN(7) DCL VAR(&DKTDEV) TYPE(*LGL) LEN(1) DCL VAR(&TAPDEV) TYPE(*LGL) LEN(1) /* Verify device name */ CHKOBJ OBJ(&SAVDEV) OBJTYPE(*DEVD) MONMSG MSGID(CPF9801) EXEC(DO) CHGVAR VAR(&MSG) VALUE('Save device' *BCAT &SAVDEV *BCAT 'not + found') GOTO CMDLBL(ERRMSG) ENDDO CHGVAR VAR(&DKTDEV) VALUE('1') CHGVAR VAR(&TAPDEV) VALUE('1') CHGDEVDKT DEVD(&SAVDEV) TEXT(*SAME) MONMSG MSGID(CPF0000) EXEC(CHGVAR VAR(&DKTDEV) VALUE('0')) CHGDEVTAP DEVD(&SAVDEV) TEXT(*SAME) MONMSG MSGID(CPF0000) EXEC(CHGVAR VAR(&TAPDEV) VALUE('0')) IF COND(*NOT &DKTDEV *AND *NOT &TAPDEV) THEN(DO) CHGVAR VAR(&MSG) VALUE('Save device' *BCAT &SAVDEV *BCAT 'is + not a diskette or tape device') GOTO CMDLBL(ERRMSG) ENDDO /* Restore necessary files from device */ RSTOBJ OBJ(SAVSPLFA) SAVLIB(QTEMP) DEV(&SAVDEV) ENDOPT(*LEAVE) RSTOBJ OBJ(SAVSPLFPF) SAVLIB(QTEMP) DEV(&SAVDEV) ENDOPT(&ENDOPT) CALL PGM(SPLF002CLA) PARM(&SPLF) GOTO CMDLBL(ENDPGM) /* Send error messages */ ERRMSG: + SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA(&MSG) MSGTYPE(*DIAG) SNDPGMMSG MSGID(CPF0002) MSGF(QCPFMSG) MSGTYPE(*ESCAPE) /* End program */ ENDPGM: + ENDPGM
Saving and Restoring Spool Files
Figure 3C CL program SPLF002CLA
SPLF002CLA: + PGM PARM(&SPLF) DCL VAR(&SPLF) TYPE(*CHAR) LEN(10) DCLF FILE(SAVSPLFA) OVRDBF FILE(SAVSPLFA) TOFILE(QTEMP/SAVSPLFA) /* Read a record from the attribute file */ RCVF: + IF COND(&SPLF *NE '*ALL') THEN(DO) OVRDBF FILE(SAVSPLFA) POSITION(*KEY 1 SSF001 &SPLF) RCVF ENDDO ELSE CMD(DO) RCVF MONMSG MSGID(CPF0864) EXEC(GOTO CMDLBL(ENDPGM)) ENDDO /* Print the restored spool file */ OVRPRTF FILE(SPLF002P1) PAGESIZE(PGLEN PGWDT) LPI(LPI) + CPI(CPI) OVRFLW(OVRFL) FOLD(FOLD) RPLUNPRT(RPUNP) + ALIGN(ALIGN) DRAWER(DRAWR) FONT(FONT) FORMFEED(FMFED) + PRTQLTY(PRQLT) CTLCHAR(*FCFC) PAGRTT(PGROT) + JUSTIFY(JSTFY) FORMTYPE(FRMTP) COPIES(CPYS) + MAXRCDS(MXRCD) FILESEP(FLSEP) SCHEDULE(SCHED) + HOLD(HOLD) SAVE(SAVF) CPYF FROMFILE(QTEMP/SAVSPLFPF) TOFILE(SPLF002P1) FROMMBR(MBR) IF COND(&SPLF *EQ '*ALL') THEN(GOTO CMDLBL(RCVF)) /* End program */ ENDPGM: + ENDPGM
LATEST COMMENTS
MC Press Online