Problem solve Get help with specific problems with your technologies, process and projects.

Renaming spool files

Change a spool file name from QSYSPRT to an RPG/400 program-generated name that will change whenever the program is called

Q: How do I change a spool file name from QSYSPRT to an RPG/400 program-generated name that will change whenever...

the program is called?

A: You can use user control (UC)OPEN and CLOSE statements and command OVRPRTF FILE(QSYSPRT) SPLFNAME(&name)in RPG program. I wrote simple RPG to represent solution.


 FQSYSPRT O   F     132            PRINTER                        UC
     INAMCMD      DS                             42
     I                                       32  41 NAME
     I              'OVRPRTF -            C         OVRCMD
     I              'FILE(QSYSPRT) -
     I              'SPLFNAME(          )'
      *
      * PREPARE COMMAND STRING *******************************
     C                     MOVELOVRCMD    NAMCMD
      ********************************************************
      *******************
      * FIRST NAME
      *******************
     C                     MOVEL'VINKO'   NAME
      * OVRPRTF **********************************************
      *       OVRPRTF FILE(QSYSPRT) SPLFNAME(&NAME)
      ********************************************************
     C                     Z-ADD42        CMDLEN 155
     C                     CALL 'QCMDEXC'
     C                     PARM           NAMCMD
     C                     PARM           CMDLEN
      ********************************************************
      * OPEN PRINT FILE **************************************
     C                     OPEN QSYSPRT
      ********************************************************
      * OUTPUT ***********************************************
     C                     EXCPTEX40
      ********************************************************
      * CLOSE PRINT FILE *************************************
     C                     CLOSEQSYSPRT
      ********************************************************
      *
      *=======================================================
      *
      *******************
      * SECOND NAME
      *******************
     C                     MOVEL'SIMON'   NAME
      * OVRPRTF **********************************************
     C                     Z-ADD42        CMDLEN 155
     C                     CALL 'QCMDEXC'
     C                     PARM           NAMCMD
     C                     PARM           CMDLEN
      ********************************************************
      * OPEN PRINT FILE **************************************
     C                     OPEN QSYSPRT
      ********************************************************
      * OUTPUT ***********************************************
     C                     EXCPTEX40
      ********************************************************
      * CLOSE PRINT FILE *************************************
     C                     CLOSEQSYSPRT
      ********************************************************
      *
      * END OF PROGRAM ***************************************
     C                     SETON                     LR
      ********************************************************
     OQSYSPRT E  203           EX40
     O                                   50 'HEADER POSITION'
     O        E  1             EX40
     O                         NAME      50
     O        E  1             EX40
     O                                   50 'END OF LIST' 
This was last published in August 2001

Dig Deeper on iSeries CL programming

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchDataCenter

Close