News Stay informed about the latest enterprise technology news and product updates.

SPLFG4CL - Program to copy spool file to text

/*********************************************************************/
/*                                                                   */
/* System ........... Utilities                                      */
/* Program........... SPLFG4CL - Program to copy spool file to text  */
/* Written by........ Sudhakar Ramakrishnan Kunji                    */
/* Date.............. Dec 12, 2000                                   */
/*                                                                   */
/*                                                                   */
/*                       Program Description                         */
/*                                                                   */
/* This Program can perform multiple operations on a Spool File.     */
/* It can perform the following:                                     */
/*                                                                   */
/*      1. Reprinting.                                               */
/*      2. Modify/Print.                                             */
/*      3. Modify/Print/Save.                                        */
/*      4. Modify/Save.                                              */
/*      5. Save/Print.                                               */
/*                                                                   */
/* It can perform operations on the entire spool file or a specified */
/* Page range.                                                       */
/*                                                                   */
/* It can copy the Spool File to either a Data Physical file or      */
/* a Source Physical file.                                           */
/*                                                                   */
/* NOTE: This program does not handle AFPDS Spool Files.             */
/*                                                                   */
/*  Parameters:                                                      */
/*    NAME        I/O     DESCRIPTION       COMMENTS                 */
/*    &FILE       Input   Spool file        Spool file to copy       */
/*    &FULLJOB    Input   Job name          Spool file job           */
/*    &SPLNBR     Input   Spool nbr         Spool file number        */
/*    &REPRINT    Input   Reprint file      Reprint spool file(Y/N)  */
/*    &MODIFY     Input   Modify file       Modify spool file (Y/N)  */
/*    &SAVMBR     Input   Save member       Save Text member  (Y/N)  */
/*    &TXTMBR     Input   Text member       Name of text member      */
/*    &TXTFILE    Input   Text file         Text file (Library/File) */
/* * * * * * * * * * * * Maintenance Log * * * * * * * * * * * * * * */
/*                                                                   */
/* Req#.       Date      Programmer     Modification Reason          */
/*                                                                   */
/*           04/15/01    Sud Kunji      Introduced additional        */
/*                                      Features.                    */
/*                                                                   */
/*********************************************************************/
             PGM        PARM(&FILE &FULLJOB &SPLNBR &REPRINT &MODIFY +
                          &SAVMBR &TXTFILE &TXTMBR &REPLACE &CRTFILE +
                          &PAGRNG &PRINTCTL)

             DCL        &FILE *CHAR LEN(10)
             DCL        &FULLJOB *CHAR LEN(26)
             DCL        &JOB *CHAR LEN(10)
             DCL        &USER *CHAR LEN(10)
             DCL        &JOBNBR *CHAR LEN(6)
             DCL        &SPLNBR *DEC  LEN(6 0)
             DCL        &REPRINT *CHAR LEN(4)
             DCL        &MODIFY *CHAR LEN(4)
             DCL        &SAVMBR *CHAR LEN(4)
             DCL        &TMPFIL *CHAR LEN(10)
             DCL        &TMPMBR *CHAR LEN(10)
             DCL        &TMPFIL2 *CHAR LEN(10)
             DCL        &TMPMBR2 *CHAR LEN(10)
             DCL        &TXTMBR *CHAR LEN(10)
             DCL        &TXTFILE *CHAR LEN(20)
             DCL        &TXTSRCF *CHAR LEN(10)
             DCL        &TXTSRCL *CHAR LEN(10)
             DCL        &REPLACE *CHAR LEN(3)
             DCL        &CRTFILE *CHAR LEN(3)
             DCL        &PAGRNG *CHAR LEN(6)
             DCL        &PRINTCTL *CHAR LEN(1)

             DCL        &ERRORSW *LGL           /* Standard error */
             DCL        &MSGID *CHAR LEN(7)     /* Standard error */
             DCL        &MSG *CHAR LEN(512)     /* Standard error */
             DCL        &MSGDTA *CHAR LEN(512)  /* Standard error */
             DCL        &MSGF *CHAR LEN(10)     /* Standard error */
             DCL        &MSGFLIB *CHAR LEN(10)  /* Standard error */
             DCL        &KEYVAR *CHAR LEN(4)    /* Standard error */
             DCL        &KEYVAR2 *CHAR LEN(4)   /* Standard error */
             DCL        &RTNTYPE *CHAR LEN(2)   /* Standard error */
             DCL        VAR(&FRPAGE)    TYPE(*DEC)  LEN(7 0)
             DCL        VAR(&TOPAGE)    TYPE(*DEC)  LEN(7 0)
             DCL        VAR(&SPLFDS)    TYPE(*CHAR) LEN(1000)
             DCL        VAR(&DSLENB)    TYPE(*CHAR) LEN(4)
             DCL        VAR(&INTJOB)    TYPE(*CHAR) LEN(16)
             DCL        VAR(&INTSPLF)   TYPE(*CHAR) LEN(16)
             DCL        VAR(&SPLNBRA)   TYPE(*CHAR) LEN(6)
             DCL        VAR(&SPLNBRB)   TYPE(*CHAR) LEN(4)
             DCL        VAR(&NBRPGSB)   TYPE(*CHAR) LEN(4)
             DCL        VAR(&NBRPGS)    TYPE(*DEC)  LEN(9 0)
             DCL        VAR(&SPLFG1WP ) TYPE(*CHAR) LEN(132)
             DCL        VAR(&FILETYPE ) TYPE(*CHAR) LEN(5)
             DCL        VAR(&PRTCTL) TYPE(*CHAR) LEN(1) VALUE('Y')
             DCL        VAR(&ERRCODE ) TYPE(*CHAR) LEN(7)

             DCLF       FILE(SPLFG1WP )

             MONMSG     MSGID(CPF0000) EXEC(GOTO STDERR1) /* Std err */
             CHGVAR     &JOB    %SST(&FULLJOB 1 10)
             CHGVAR     &USER   %SST(&FULLJOB 11 10)
             CHGVAR     &JOBNBR %SST(&FULLJOB 21  6)
             CHGVAR     &TXTSRCF %SST(&TXTFILE 1 10)
             CHGVAR     &TXTSRCL %SST(&TXTFILE 11 10)
             CHGVAR     VAR(&TMPFIL) VALUE('SPLFG4WP')
             CHGVAR     VAR(&TMPMBR) VALUE('SPLFG4WP')
             CHGVAR     VAR(&TMPFIL2) VALUE('SPLFIL01')
             CHGVAR     VAR(&TMPMBR2) VALUE('SPLFIL01')

             CHGVAR     VAR(&SPLNBRA) VALUE(&SPLNBR)

             CLRPFM     FILE(SPLFG1WP)

             IF         COND((&TXTMBR *EQ '          ')              +
                          *OR (&TXTMBR *EQ '*FILE     ')) THEN(DO)
               CHGVAR     VAR(&TXTMBR) VALUE(&TXTFILE)
             ENDDO

             IF         COND((&TXTMBR *EQ '          ')              +
                          *OR (&TXTMBR *EQ '*SPLFILE  ')) THEN(DO)
               CHGVAR     VAR(&TXTMBR) VALUE(&FILE)
             ENDDO

             IF         COND((&SPLNBR *NE -1) *AND (&SPLNBR *NE -2)) +
                          THEN(DO)
               OUTFILE    COMMAND(WRKSPLFA FILE(&FILE) +
                            JOB(&JOBNBR/&USER/&JOB) SPLNBR(&SPLNBRA) +
                            OUTPUT(*PRINT)) OUTFILE(QTEMP/SPLFG1WP) +
                            DLTSPLF(*YES)
             ENDDO

             IF         COND(&SPLNBR *EQ -2) THEN(DO)
               CHGVAR     VAR(&SPLNBRA) VALUE('*LAST')
               OUTFILE    COMMAND(WRKSPLFA FILE(&FILE) +
                            JOB(&JOBNBR/&USER/&JOB) SPLNBR(&SPLNBRA) +
                            OUTPUT(*PRINT)) OUTFILE(QTEMP/SPLFG1WP) +
                            DLTSPLF(*YES)
               RCVF       RCDFMT(SPLFG1WP )
               RCVF       RCDFMT(SPLFG1WP )
               RCVF       RCDFMT(SPLFG1WP )
               CHGVAR     VAR(&SPLNBRA) VALUE(%SST(&SPLFG1WP  71 6))
               CHGVAR     VAR(&SPLNBR) VALUE(&SPLNBRA)
             ENDDO

             IF         COND(&SPLNBR *EQ -1) THEN(DO)
               CHGVAR     VAR(&SPLNBRA) VALUE('*ONLY')
               OUTFILE    COMMAND(WRKSPLFA FILE(&FILE) +
                            JOB(&JOBNBR/&USER/&JOB) SPLNBR(&SPLNBRA) +
                            OUTPUT(*PRINT)) OUTFILE(QTEMP/SPLFG1WP) +
                            DLTSPLF(*YES)

               RCVF       RCDFMT(SPLFG1WP )
               MONMSG     MSGID(CPF0000) EXEC(DO)
                 SNDPGMMSG  MSG('Duplicate Spool files found.')
                 GOTO       CMDLBL(RETN)
               ENDDO

               RCVF       RCDFMT(SPLFG1WP )
               RCVF       RCDFMT(SPLFG1WP )
               CHGVAR     VAR(&SPLNBRA) VALUE(%SST(&SPLFG1WP  71 6))
               CHGVAR     VAR(&SPLNBR) VALUE(&SPLNBRA)
             ENDDO

             OVRDBF     FILE(SPLFG1WP ) POSITION(*RRN 19)
             RCVF       RCDFMT(SPLFG1WP )
             DLTOVR     FILE(SPLFG1WP )

             IF         COND((%SST(&SPLFG1WP  47 6) = '*AFPDS') *OR +
                          (%SST(&SPLFG1WP  47 5) = '*IPDS')) THEN(DO)
               SNDPGMMSG  MSG('Cannot Handle AFPDS/IPDS Spool Files! +
                            Contact Technical Support.')
               RETURN
             ENDDO

             CHGVAR     VAR(&SPLNBRA) VALUE(&SPLNBR)

             DLTOVR     FILE(&TMPFIL)
             MONMSG     MSGID(CPF0000)
             DLTF       FILE(QTEMP/&TMPFIL)
             MONMSG     MSGID(CPF2105)   /* file not found */
             CPYF       FROMFILE(&TMPFIL) TOFILE(QTEMP/&TMPFIL) +
                          MBROPT(*REPLACE) CRTFILE(*YES)
             CLRPFM     FILE(QTEMP/&TMPFIL)

             IF         (&FULLJOB *EQ '*') DO /* Use current job */
               CPYSPLF    FILE(&FILE) TOFILE(QTEMP/&TMPFIL) +
                            SPLNBR(&SPLNBRA) TOMBR(&TMPMBR) +
                            MBROPT(*ADD) CTLCHAR(*PRTCTL)
             ENDDO      /* Use current job */

             IF         (&FULLJOB *NE '*') DO /* Specific job name */
               IF         (&USER *EQ '  ') CHGVAR &USER '*N'
               IF         (&JOBNBR *EQ '  ') CHGVAR &JOBNBR '*N'
               CPYSPLF    FILE(&FILE) TOFILE(QTEMP/&TMPFIL) +
                            JOB(&JOBNBR/&USER/&JOB) SPLNBR(&SPLNBRA) +
                            TOMBR(&TMPMBR) MBROPT(*ADD) +
                            CTLCHAR(*PRTCTL)
             ENDDO      /* Specific job name used */

/*  Build work variables used for parameters to attribute API.     */
             CHGVAR     VAR(&DSLENB) VALUE(X'000003E8') /* Change +
                          length to the hex form of '1000' */
             CHGVAR     VAR(%BIN(&SPLNBRB 1 4)) VALUE(&SPLNBR)
/*  Call API                                                       */
             CALL       PGM(QUSRSPLA) PARM(&SPLFDS &DSLENB +
                          'SPLA0100' &FULLJOB &INTJOB &INTSPLF &FILE +
                          &SPLNBRB)
/*  Retrieve results:                                              */
             CHGVAR     VAR(&NBRPGSB) VALUE(%SST(&SPLFDS 141 4))
             CHGVAR     VAR(&NBRPGS) VALUE(%BIN(&NBRPGSB 1 4))

             CHGVAR     VAR(&FRPAGE) VALUE(%BIN(&PAGRNG  3 2))
             CHGVAR     VAR(&TOPAGE) VALUE(%BIN(&PAGRNG  5 2))

             IF         COND(&TOPAGE *GT &NBRPGS) THEN(DO)
               SNDPGMMSG  MSG('To Page cannot be greater than Total +
                            number of Pages')
               GOTO       RETN
             ENDDO

             IF         COND(&FRPAGE *EQ 0) THEN(DO)
               SNDPGMMSG  MSG('From Page cannot be Zeros.')
               GOTO       RETN
             ENDDO

             IF         COND(&TOPAGE *EQ 0) THEN(DO)
               SNDPGMMSG  MSG('To Page cannot be Zeros.')
               GOTO       RETN
             ENDDO

             IF         COND((&FRPAGE = -2) *AND (&TOPAGE = -1)) +
                          THEN(GOTO CMDLBL(SKIPPGCALC))

             IF         COND(&TOPAGE = -2) THEN(CHGVAR VAR(&TOPAGE) +
                          VALUE(1))

             IF         COND(&FRPAGE = -2) THEN(CHGVAR VAR(&FRPAGE) +
                          VALUE(1))

             IF         COND(&TOPAGE = -1) THEN(CHGVAR VAR(&TOPAGE) +
                          VALUE(&NBRPGS))

             IF         COND(&FRPAGE = -1) THEN(CHGVAR VAR(&FRPAGE) +
                          VALUE(&NBRPGS))

             IF         COND(&FRPAGE *GT &TOPAGE) THEN(DO)
               SNDPGMMSG  MSG('From Page cannot be greater than to +
                            Page.')
               GOTO       RETN
             ENDDO

             DLTF       FILE(QTEMP/SPLFGIWP)
             MONMSG     MSGID(CPF2105)   /* file not found */
             CPYF       FROMFILE(SPLFGIWP) TOFILE(QTEMP/SPLFGIWP) +
                          MBROPT(*REPLACE) CRTFILE(*YES)

             DLTF       FILE(QTEMP/SPLFGOWP)
             MONMSG     MSGID(CPF2105)   /* file not found */
             CPYF       FROMFILE(SPLFGOWP) TOFILE(QTEMP/SPLFGOWP) +
                          MBROPT(*REPLACE) CRTFILE(*YES)

             CPYF       FROMFILE(QTEMP/&TMPFIL) +
                          TOFILE(*LIBL/SPLFGIWP) MBROPT(*REPLACE) +
                          CRTFILE(*NO) FMTOPT(*NOCHK)

             CHGVAR     VAR(&ERRCODE) VALUE('       ')

             CALL       PGM(SPLFG4RP) PARM(&FRPAGE &TOPAGE &PRTCTL +
                          &ERRCODE)

             IF         COND(&ERRCODE *NE '       ') THEN(DO)
               SNDPGMMSG  MSG('Command ended in Error!')
               GOTO       RETN
             ENDDO

             CPYF       FROMFILE(*LIBL/SPLFGOWP) +
                          TOFILE(QTEMP/&TMPFIL) MBROPT(*REPLACE) +
                          CRTFILE(*NO) FMTOPT(*NOCHK)

  SKIPPGCALC:

             IF         COND((&MODIFY = '*NO')                 *AND +
                          (&SAVMBR = '*YES')) THEN(DO)

               IF         COND(&CRTFILE *EQ '1') THEN(DO)
                 CHKOBJ     OBJ(&TXTSRCL/&TXTSRCF) OBJTYPE(*FILE)
                 MONMSG     MSGID(CPF9801) EXEC(DO)
                   CPYF       FROMFILE(QTEMP/&TMPFIL) +
                                TOFILE(&TXTSRCL/&TXTSRCF) CRTFILE(*YES)
                   RMVM       FILE(&TXTSRCL/&TXTSRCF) MBR(*ALL)
                 ENDDO
               ENDDO

               IF         COND(&REPLACE *EQ '1') THEN(DO)
                 RMVM       FILE(&TXTSRCL/&TXTSRCF) MBR(&TXTMBR)
                 MONMSG     MSGID(CPF0000)
               ENDDO

               ADDPFM     FILE(&TXTSRCL/&TXTSRCF) MBR(&TXTMBR) +
                            TEXT('Member created by CPYSPLFIL - +
                            Spool file ' *CAT &FILE) SRCTYPE(TXT)

               RTVMBRD    FILE(&TXTSRCL/&TXTSRCF) FILETYPE(&FILETYPE)

               IF         COND(&FILETYPE = '*SRC ') THEN(DO)
                 IF         COND(&PRINTCTL = '1') THEN(DO)
                   DLTF       FILE(QTEMP/SPLFX4WP)
                   MONMSG     MSGID(CPF0000)
                   CPYF       FROMFILE(SPLFX4WP) +
                                TOFILE(QTEMP/SPLFX4WP) +
                                MBROPT(*REPLACE) CRTFILE(*YES)
                   CLRPFM     FILE(QTEMP/SPLFX4WP)
                   CALL       PGM(SPLFX4RP) PARM('2')
                   CPYF       FROMFILE(QTEMP/SPLFX4WP) +
                                TOFILE(&TMPFIL) MBROPT(*REPLACE) +
                                CRTFILE(*NO) FMTOPT(*NOCHK)
                 ENDDO
                 CPYF       FROMFILE(QTEMP/&TMPFIL) +
                              TOFILE(&TXTSRCL/&TXTSRCF) +
                              FROMMBR(&TMPMBR) TOMBR(&TXTMBR) +
                              MBROPT(*REPLACE) CRTFILE(*NO) +
                              FMTOPT(*CVTSRC)
               ENDDO
               ELSE       CMD(DO)
                 IF         COND(&PRINTCTL = '1') THEN(DO)
                   DLTF       FILE(QTEMP/SPLFX4WP)
                   MONMSG     MSGID(CPF0000)
                   CPYF       FROMFILE(SPLFX4WP) +
                                TOFILE(QTEMP/SPLFX4WP) +
                                MBROPT(*REPLACE) CRTFILE(*YES)
                   CLRPFM     FILE(QTEMP/SPLFX4WP)
                   CALL       PGM(SPLFX4RP) PARM('2')
                   CPYF       FROMFILE(QTEMP/SPLFX4WP) +
                                TOFILE(&TMPFIL) MBROPT(*REPLACE) +
                                CRTFILE(*NO) FMTOPT(*NOCHK)
                 ENDDO
                 CPYF       FROMFILE(QTEMP/&TMPFIL) +
                              TOFILE(&TXTSRCL/&TXTSRCF) +
                              FROMMBR(&TMPMBR) TOMBR(&TXTMBR) +
                              MBROPT(*REPLACE) CRTFILE(*NO) +
                              FMTOPT(*NOCHK)
               ENDDO

               IF         COND(&REPRINT *EQ '*NO') THEN(DO)
                 SNDPGMMSG  MSG('Spool file Copied to Physical File')
                 GOTO       CMDLBL(RETN)
               ENDDO

               DLTF       FILE(QTEMP/&TMPFIL2)
               MONMSG     MSGID(CPF2105)   /* file not found */
               CRTSRCPF   FILE(QTEMP/&TMPFIL2) RCDLEN(150) +
                            MBR(&TMPMBR2)

               CPYF       FROMFILE(QTEMP/&TMPFIL) +
                            TOFILE(QTEMP/&TMPFIL2) MBROPT(*REPLACE) +
                            CRTFILE(*NO) FMTOPT(*CVTSRC) ERRLVL(*NOMAX)
               CHGPFM     FILE(QTEMP/&TMPFIL2) MBR(&TMPMBR2) +
                            SRCTYPE(TXT)
               GOTO       CMDLBL(PRINTING)

             ENDDO

             DLTF       FILE(QTEMP/&TMPFIL2)
             MONMSG     MSGID(CPF2105)   /* file not found */
             CRTSRCPF   FILE(QTEMP/&TMPFIL2) RCDLEN(150) MBR(&TMPMBR2)

             CPYF       FROMFILE(QTEMP/&TMPFIL) +
                          TOFILE(QTEMP/&TMPFIL2) MBROPT(*REPLACE) +
                          CRTFILE(*NO) FMTOPT(*CVTSRC) ERRLVL(*NOMAX)
             CHGPFM     FILE(QTEMP/&TMPFIL2) MBR(&TMPMBR2) SRCTYPE(TXT)

             IF         COND(&MODIFY *EQ '*YES') THEN(DO)
               RMVMSG     CLEAR(*ALL)
               STRSEU     SRCFILE(QTEMP/&TMPFIL2) SRCMBR(&TMPMBR2) +
                            TYPE(TXT) OPTION(2)
             ENDDO


             IF         COND(&REPRINT *EQ '*NO') THEN(GOTO +
                          CMDLBL(AFTERPRINT))

PRINTING:
             OVRDBF     FILE(SPLFG4WP) TOFILE(QTEMP/&TMPFIL2) +
                          MBR(&TMPMBR2)
             OVRPRTF    FILE(QPRINT) USRDTA(CPYSPLFIL) +
                          SPLFNAME(&FILE) SECURE(*YES)

             CALL       PGM(SPLFX4RP) PARM('1')

             SNDPGMMSG  MSGID(CPI9801) MSGF(QCPFMSG) TOPGMQ(*EXT) +
                          MSGTYPE(*STATUS) /* Blank status message */
             SNDPGMMSG  MSGID(CPF9898) MSGF(QCPFMSG) TOPGMQ(*EXT) +
                          MSGDTA('Reprinting spooled file ' *CAT +
                          &FILE) MSGTYPE(*STATUS)
             SNDPGMMSG  MSGID(CPI9801) MSGF(QCPFMSG) TOPGMQ(*EXT) +
                          MSGTYPE(*STATUS) /* Blank status message */

             DLTOVR     FILE(SPLFG4WP)
             DLTOVR     FILE(QPRINT)

             RMVMSG     CLEAR(*ALL)

             IF         COND(&MODIFY = '*YES') THEN(DO)
               SNDPGMMSG  MSG('Spooled file ' *CAT &FILE  *TCAT ' +
                            has been modified and reprinted.')  +
                            MSGTYPE(*COMP)
             ENDDO
             ELSE       CMD(DO)
               IF         COND(&SAVMBR = '*YES') THEN(DO)
                 SNDPGMMSG  MSG('Spooled file ' *CAT &FILE *TCAT ' +
                              has been Saved and Reprinted.') +
                              MSGTYPE(*COMP)
               ENDDO
               ELSE       CMD(DO)
                 SNDPGMMSG  MSG('Spooled file ' *CAT &FILE *TCAT ' +
                              has been Reprinted.') MSGTYPE(*COMP)
               ENDDO
             ENDDO

 AFTERPRINT:
             IF         COND(&SAVMBR *EQ '*NO' *OR &TXTFILE *EQ ' ') +
                          THEN(GOTO CMDLBL(RETN))

             IF         COND(&CRTFILE *EQ '1') THEN(DO)
               CHKOBJ     OBJ(&TXTSRCL/&TXTSRCF) OBJTYPE(*FILE)
               MONMSG     MSGID(CPF9801) EXEC(DO)
                 CPYF       FROMFILE(QTEMP/&TMPFIL2) +
                              TOFILE(&TXTSRCL/&TXTSRCF) CRTFILE(*YES)
                 RMVM       FILE(&TXTSRCL/&TXTSRCF) MBR(*ALL)
               ENDDO
             ENDDO


             IF         COND(&REPLACE *EQ '1') THEN(DO)
               RMVM       FILE(&TXTSRCL/&TXTSRCF) MBR(&TXTMBR)
               MONMSG     MSGID(CPF0000)
             ENDDO

             ADDPFM     FILE(&TXTSRCL/&TXTSRCF) MBR(&TXTMBR) +
                          TEXT('Member created by CPYSPLFIL - Spool +
                          file ' *CAT &FILE) SRCTYPE(TXT)

             RTVMBRD    FILE(&TXTSRCL/&TXTSRCF) FILETYPE(&FILETYPE)

             IF         COND(&FILETYPE = '*DATA') THEN(DO)
               IF         COND(&PRINTCTL = '1') THEN(DO)
                 CPYF       FROMFILE(QTEMP/&TMPFIL2) +
                              TOFILE(QTEMP/&TMPFIL) MBROPT(*REPLACE) +
                              CRTFILE(*NO ) FMTOPT(*CVTSRC)
                 DLTF       FILE(QTEMP/SPLFX4WP)
                 MONMSG     MSGID(CPF0000)
                 CPYF       FROMFILE(SPLFX4WP) +
                              TOFILE(QTEMP/SPLFX4WP) +
                              MBROPT(*REPLACE) CRTFILE(*YES)
                 CLRPFM     FILE(QTEMP/SPLFX4WP)
                 CALL       PGM(SPLFX4RP) PARM('2')
                 CPYF       FROMFILE(QTEMP/SPLFX4WP) +
                              TOFILE(&TMPFIL2) TOMBR(&TMPMBR2) +
                              MBROPT(*REPLACE) CRTFILE(*NO) +
                              FMTOPT(*CVTSRC)
               ENDDO
               CPYF       FROMFILE(QTEMP/&TMPFIL2) +
                            TOFILE(&TXTSRCL/&TXTSRCF) +
                            FROMMBR(&TMPMBR2) TOMBR(&TXTMBR) +
                            MBROPT(*REPLACE) CRTFILE(*NO ) +
                            FMTOPT(*CVTSRC)
             ENDDO
             ELSE       CMD(DO)
               IF         COND(&PRINTCTL = '1') THEN(DO)
                 CPYF       FROMFILE(QTEMP/&TMPFIL2) +
                              TOFILE(QTEMP/&TMPFIL) MBROPT(*REPLACE) +
                              CRTFILE(*NO ) FMTOPT(*CVTSRC)
                 DLTF       FILE(QTEMP/SPLFX4WP)
                 MONMSG     MSGID(CPF0000)
                 CPYF       FROMFILE(SPLFX4WP) +
                              TOFILE(QTEMP/SPLFX4WP) +
                              MBROPT(*REPLACE) CRTFILE(*YES)
                 CLRPFM     FILE(QTEMP/SPLFX4WP)
                 CALL       PGM(SPLFX4RP) PARM('2')
                 CPYF       FROMFILE(QTEMP/SPLFX4WP) +
                              TOFILE(&TMPFIL2) TOMBR(&TMPMBR2) +
                              MBROPT(*REPLACE) CRTFILE(*NO) +
                              FMTOPT(*CVTSRC)
               ENDDO
               CPYF       FROMFILE(QTEMP/&TMPFIL2) +
                            TOFILE(&TXTSRCL/&TXTSRCF) +
                            FROMMBR(&TMPMBR2) TOMBR(&TXTMBR) +
                            MBROPT(*REPLACE) CRTFILE(*NO ) +
                            FMTOPT(*NOCHK)
             ENDDO

             RMVMSG     CLEAR(*ALL)

 RETN:
             RETURN     /* Normal end for MODIFY(*YES) */

 STDERR1:               /* Standard error handling routine */
             IF         &ERRORSW SNDPGMMSG MSGID(CPF9999) +
                          MSGF(QCPFMSG) MSGTYPE(*ESCAPE)
             CHGVAR     &ERRORSW '1' /* Set to fail on error */
             RCVMSG     MSGTYPE(*EXCP) RMV(*NO) KEYVAR(&KEYVAR)
 STDERR2:    RCVMSG     MSGTYPE(*PRV) MSGKEY(&KEYVAR) RMV(*NO) +
                          KEYVAR(&KEYVAR2) MSG(&MSG) MSGDTA(&MSGDTA) +
                          MSGID(&MSGID) RTNTYPE(&RTNTYPE) +
                          MSGF(&MSGF) SNDMSGFLIB(&MSGFLIB)
             IF         (&RTNTYPE *NE '02') GOTO STDERR3
             IF         (&MSGID *NE ' ') SNDPGMMSG MSGID(&MSGID) +
                          MSGF(&MSGFLIB/&MSGF) MSGDTA(&) +
                          MSGTYPE(*DIAG)
             IF         (&MSGID *EQ ' ') SNDPGMMSG MSG(&MSG) +
                          MSGTYPE(*DIAG)
             RMVMSG     MSGKEY(&KEYVAR2)
 STDERR3:    RCVMSG     MSGKEY(&KEYVAR) MSGDTA(&MSGDTA) +
                          MSGID(&MSGID) MSGF(&MSGF) +
                          SNDMSGFLIB(&MSGFLIB)
             SNDPGMMSG  MSGID(&MSGID) MSGF(&MSGFLIB/&MSGF) +
                          MSGDTA(&MSGDTA) MSGTYPE(*ESCAPE)
             ENDPGM

Dig Deeper on iSeries programming commands

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchDataCenter

Close