Using CPYSPLF to Re-Create a Spooled File or Create a PC File

Technote (troubleshooting)


Problem(Abstract)

This document provides information on using the Copy Spooled File (CPYSPLF) command to re-create an operating system spooled file or create a PC text file.

Resolving the problem

This document shows different uses of the Copy Spooled File (CPYSPLF) command including how to re-create a spooled file with different attributes or how to create a PC file from an existing spooled file.

Notes:

o The CPYSPLF command can be used to copy *SCS and *LINE spooled files, those spooled files that are generated with the Printer device type (DEVTYPE) parameter set to *SCS or *LINE in the spooled file attributes; however, this does not work on *AFPDS or *USERASCII spooled files and may not work on *IPDS spooled files.
o Running the CPYSPLF command on *USERASCII spooled files will result in receiving message CPF3429 "File &1 number &7 cannot be displayed, copied, or sent" with reason code 3, which indicates that the spooled file "contains only ASCII data intended for a personal computer printer".
o Running the CPYSPLF command on *AFPDS spooled files will result in receiving message CPF3429 with reason code 4, which indicates that the spooled file "contains only advanced function printing data stream (AFPDS) data".

In this case, the best option would be to copy the text of the *AFPDS spooled file to a PC using System i Navigator, using the instructions in the following document, if needed:

N1019300: Copying the Text from a Spooled File Using System i Navigator

and then using FTP in ASCII mode to copy the data from the PC text file back to a physical file member. For more information, refer to Example 7: Copying the Data from an ASCII Text File on a PC Back to an Physical File Member Using FTP below.
o The CPYSPLF command also does not work with spooled files that have control characters and are generated with the Unprintable character action (RPLUNPRT) parameter set to *NO in the spooled file attributes.
o Starting in 7.1 i5/OS, the Copy Spooled File (CPYSPLF) command can be used to copy spooled files to a stream file in the Integrated File System (IFS). The spooled files can optionally be converted using a workstation customizing object, which allows the spooled file to be converted to other formats. To convert the spooled files to Portable Document Format (PDF), you must download and apply 7.1 PTF SI43471 or a superseding PTF and you must also install licensed program 5770TS1, *BASE and Option 1, "IBM Transform Services for i" and "Transforms - AFP to PDF Transform".

For more information, please refer to the following document:

N1011580: New CPYSPLF function to copy SPLFs to Stream Files in the IFS

as well as the following APAR and PTF cover letters:

APAR SE47834 OSP-PRT ENHANCEMENTS TO CPYSPLF COMMAND
7.1 PTF SI43471

This document was last updated on 22 July 2014.



    • - Copying a Spooled File to a Physical File Member with First Character Form Control (FCFC) Information


      The instructions in this section explain how to copy a spooled file to a physical file member with First Character Form Control (FCFC) information. There is an extra byte for storing the First Character Form Control (FCFC) information, which is used to preserve the line spacing and page breaks in the spooled file. Therefore this method should be used when you need to copy the text of the spooled file with the line and page breaks, and the CPYF command will be used with CTLCHAR(*FCFC) to interpret the FCFC controls (or when a program is available to interpret the FCFC control information instead).

      To copy the spooled file to a physical file member with the First Character Form Control (FCFC) information, do the following:

      1 First, you will need to create a physical file with a record length 1 greater than the record length of the spooled file. This extra byte will be used for a First Character Form Control (or FCFC) character which will preserve the line spacing and page breaks in the spooled file.

      To determine the record length of the spooled file, use either the Work with Output Queue (WRKOUTQ) or Work with Spooled Files (WRKSPLF) command and find the spooled file that you wish to copy.
      2 Press the F21 (select assistance level) key and make sure that the assistance level is set to 2 (intermediate).
      3 Type option 8 (attributes) next to the spooled file and press the Enter key. This will take you to the Work with Spooled File Attributes screen.
      4 Use the Page Down key to scroll down 4 or 5 pages until you find the entry for Page size.
      5a If the intent is to copy a spooled file without modifying any of the data in the spooled file, then a physical file should be created using the Create Physical File (CRTPF) command.

      Look to see the value specified for the Width, then use one of the following CRTPF commands to create a physical file to store the data from the spooled files. If the page width is 132, use the following command to create a physical file with a record length of 133 bytes:

      CRTPF library/file_name  RCDLEN(133) MAXMBRS(*NOMAX)
            SIZE(*NOMAX) LVLCHK(*NO)

      If the page width is 198, use the following command to create a physical file with a record length of 199 bytes:

      CRTPF library/file_name  RCDLEN(199) MAXMBRS(*NOMAX)
            SIZE(*NOMAX) LVLCHK(*NO)

      Note: If copying text from a secondary language, you must use an externally described physical file created using SQL or Data Description Specifications (DDS), rather than using the Create Physical File (CRTPF) command. For more information on copying spooled files with a secondary CCSID, refer to the following Rochester Support Center knowledgebase document:

      N1019721: Data Transfer and CCSID 65535 Database Files
      5b If the intent is to copy a spooled file, modify the data in the spooled file, and then copy it back to a new spooled file, then a source physical file should be created using the Create Source Physical File (CRTSRCPF) command. That will allow the member to be edited using either the Start Source Entry Utility (STRSEU) or Work with Members Using PDM (WRKMBRPDM) commands.

      Look to see the value specified for the Width, then use one of the following CRTSRCPF commands to create a physical file to store the data from the spooled files. The source physical file should be created with a record length at least 13 columns greater than the page width to accommodate not only the First Character Form Control (FCFC) byte, but also the source sequence number (which contains 6 bytes) and the date (which contains 6 bytes) which exist on each line of text in the source physical file member. For example, if the page width is 132, use the following command to create a source physical file with a record length of 145:

      CRTSRCPF  FILE(library/source_physical_file)  RCDLEN(145)

      If the page width is 198 bytes, use the following command to create a source physical file with a record length of 211:

      CRTSRCPF  FILE(library/source_physical_file)  RCDLEN(211)
      6 Find out the job qualifier, file name, and spooled file number for this spooled file. This can be found by typing option 8 (attributes) next to the spooled file and pressing the Enter key. The job qualifier, file name, and spooled file number are shown at the top of the Work with Spooled File Attributes screen.
      7 Use the following Copy Spooled File (CPYSPLF) command to copy the data from the spooled file to the physical file:

      CPYSPLF FILE(spooled_file_name) JOB(number/user/job)
              TOFILE(library/file_name) TOMBR(member_name)
              MBROPT(*REPLACE) CTLCHAR(*FCFC)
      8 At this point, the spooled file has been copied to the physical file member.
      Once the spooled file has been copied to the physical file member you do several different things with it, including:
      o Save it to media (for archives) or a save file
      o Restore it from media or a save file
      o Create a new spooled file
      o Create a new spooled file with different attributes
      o Create a new spooled file after modifying the database member
      o Create a PCFILE
      Typically, you will next follow the instructions in one of the following sections to copy the print data in the physical file member to a new spooled file:
      o Example 1: Creating a New Spooled File with Different Attributes
      o Example 2: Modifying the Physical File Member and Rewriting the Spooled File

      • - Copying Several Spooled Files into a Single Physical File Member with First Character Form Control (FCFC) Information


        The Copy Spooled File (CPYSPLF) command can be used to copy several spooled files into a single physical file member by setting the Replace or add records (MBROPT) parameter to *ADD instead of using the default value of *REPLACE. The instructions in this section explain how to copy several spooled files to a single physical file member with First Character Form Control (FCFC) information. That physical file member can then be copied to a printer file to effectively combine several spooled files into single new spooled file.

        The physical file is created with an extra byte for storing the First Character Form Control (FCFC) information, which is used to record the line spacing and page breaks in the spooled file. The Copy Spooled File (CPYSPLF) command must be used with CTLCHAR(*FCFC) to record the page breaks and line breaks, including the page breaks between each original spooled file, and the Copy File (CPYF) command must also be used with CTLCHAR(*FCFC) to interpret the FCFC controls.

        To copy the spooled file to a physical file member with the First Character Form Control (FCFC) information, do the following:

        1 First, you will need to create a physical file with a record length 1 greater than the record length of the spooled file. This extra byte will be used for a First Character Form Control (or FCFC) character which will preserve the line spacing and page breaks in the spooled file.

        To determine the record length of the spooled file, use either the Work with Output Queue (WRKOUTQ) or Work with Spooled Files (WRKSPLF) command and find the spooled file that you wish to copy.
        2 Press the F21 (select assistance level) key and make sure that the assistance level is set to 2 (intermediate).
        3 Type option 8 (attributes) next to the spooled file and press the Enter key. This will take you to the Work with Spooled File Attributes screen.
        4 Use the Page Down key to scroll down 4 or 5 pages until you find the entry for Page size.
        5a If the intent is to copy a spooled file without modifying any of the data in the spooled file, then a physical file should be created using the Create Physical File (CRTPF) command.

        Look to see the value specified for the Width, then use one of the following CRTPF commands to create a physical file to store the data from the spooled files. If the page width is 132, use the following command to create a physical file with a record length of 133 bytes:

        CRTPF library/file_name RCDLEN(133) MAXMBRS(*NOMAX)
              SIZE(*NOMAX) LVLCHK(*NO)

        If the page width is 198, use the following command to create a physical file with a record length of 199 bytes:

        CRTPF library/file_name RCDLEN(199) MAXMBRS(*NOMAX)
              SIZE(*NOMAX) LVLCHK(*NO)
        5b If the intent is to copy a spooled file, modify the data in the spooled file, and then copy it back to a new spooled file, then a source physical file should be created using the Create Source Physical File (CRTSRCPF) command. That will allow the member to be edited using either the Start Source Entry Utility (STRSEU) or Work with Members Using PDM (WRKMBRPDM) commands.

        Look to see the value specified for the Width, then use one of the following CRTSRCPF commands to create a physical file to store the data from the spooled files. The source physical file should be created with a record length at least 13 columns greater than the page width to accommodate not only the First Character Form Control (FCFC) byte, but also the source sequence number (which contains 6 bytes) and the date (which contains 6 bytes) which exist on each line of text in the source physical file member. For example, if the page width is 132, use the following command to create a source physical file with a record length of 145:

        CRTSRCPF FILE(library/source_physical_file) RCDLEN(145)

        If the page width is 198 bytes, use the following command to create a source physical file with a record length of 211:

        CRTSRCPF FILE(library/source_physical_file) RCDLEN(211)
        6 Find out the job qualifier, file name, and spooled file number for this spooled file. This can be found by typing option 8 (attributes) next to the spooled file and pressing the Enter key. The job qualifier, file name, and spooled file number are shown at the top of the Work with Spooled File Attributes screen.
        7 Use the following Copy Spooled File (CPYSPLF) command to copy the data from the spooled file to the physical file member:

        CPYSPLF FILE(spooled_file_name) JOB(number/user/job)
                TOFILE(library/file_name) TOMBR(member_name)
                MBROPT(*REPLACE) CTLCHAR(*FCFC)

        Note: The CPYSPLF command can be specified with MBROPT(*ADD) for the first spooled file as well, but using MBROPT(*REPLACE) will ensure that the member does not contain any data from other spooled files or from previous times using the CPYSPLF command.
        8 At this point, the first spooled file will have been copied to the physical file member. Next use the following Copy Spooled File (CPYSPLF) command for the remaining spooled files to add them to the end of the existing physical file member, which combine all of the spooled files into a single physical file member:

        CPYSPLF FILE(spooled_file_name) JOB(number/user/job)
                TOFILE(library/file_name) TOMBR(member_name)
                MBROPT(*ADD) CTLCHAR(*FCFC)
        9 Repeat Step 8 until all of the spooled files have been copied to the same physical file member.
        Once the spooled file has been copied to the physical file member you do several different things with it, including:
        o Save it to media (for archives) or a save file
        o Restore it from media or a save file
        o Create a new spooled file
        o Create a new spooled file with different attributes
        o Create a new spooled file after modifying the database member
        o Create a PCFILE
        Typically, you will next follow the instructions in one of the following sections to copy the print data in the physical file member to a new spooled file:
        o Example 1: Creating a New Spooled File with Different Attributes
        o Example 2: Modifying the physical file member and Rewriting the Spooled File

        • - Copying a Spooled File to a Physical File Member without First Character Form Control (FCFC) Information


          The instructions in this section explain how to copy a spooled file to a physical file member without First Character Form Control (FCFC) information. There is no extra byte for storing the First Character Form Control (FCFC) information. There is nothing to preserve the line spacing and page breaks in the spooled file. Therefore, this method should be used only when you need to copy the text of the spooled file without the line and page breaks or when there is no program available to interpret the FCFC control information (for example, on a PC).

          To copy the spooled file to a physical file member without the First Character Form Control (FCFC) information, do the following:

          1 Create a physical file using the CRTPF command with a record length equal to the record length of the spooled file.

          To determine the record length of the spooled file, use the Work with Output Queue (WRKOUTQ) or Work with Spooled Files (WRKSPLF) command and find the spooled file that you wish to copy.
          2 Press the F21 (select assistance level) key, and ensure that the assistance level is set to 2 (intermediate).
          3 Type Option 8 (attributes) next to the spooled file, and press the Enter key. This takes you to the Work with Spooled File Attributes screen.
          4 Use the Page Down key to scroll down 4 or 5 pages until you find the entry for Page size.
          5a If the intent is to copy a spooled file without modifying any of the data in the spooled file, then a physical file should be created using the Create Physical File (CRTPF) command.

          Look to see the value specified for the Width, then use one of the following CRTPF commands to create a physical file to store the data from the spooled files. If the page width is 132, use the following command to create a physical file with a record length of 132 bytes, since an extra byte is not needed for the First Character Form Control (FCFC):

          CRTPF library/file_name RCDLEN(132) MAXMBRS(*NOMAX)
                SIZE(*NOMAX) LVLCHK(*NO)

          If the page width is 198, use the following command to create a physical file with a record length of 198 bytes, since an extra byte is not needed for the First Character Form Control (FCFC):

          CRTPF library/file_name RCDLEN(198) MAXMBRS(*NOMAX)
                SIZE(*NOMAX) LVLCHK(*NO)
          5b If the intent is to copy a spooled file, modify the data in the spooled file, and then copy it back to a new spooled file, then a source physical file should be created using the Create Source Physical File (CRTSRCPF) command. That will allow the member to be edited using either the Start Source Entry Utility (STRSEU) or Work with Members Using PDM (WRKMBRPDM) commands.

          Look to see the value specified for the Width, then use one of the following CRTSRCPF commands to create a physical file to store the data from the spooled files. The source physical file should be created with a record length at least 12 columns greater than the page width to accommodate the source sequence number (which contains 6 bytes) and the date (which contains 6 bytes) which exist on each line of text in the source physical file member. For example, if the page width is 132, use the following command to create a source physical file with a record length of 144, since an extra byte is not needed for the First Character Form Control (FCFC):

          CRTSRCPF FILE(library/source_physical_file) RCDLEN(144)

          If the page width is 198 bytes, use the following command to create a source physical file with a record length of 210, since an extra byte is not needed for the First Character Form Control (FCFC):

          CRTSRCPF FILE(library/source_physical_file) RCDLEN(210)
          6 Determine the job qualifier, file name, and spooled file number for this spooled file. This can be found by typing Option 8 (attributes) next to the spooled file, and pressing the Enter key. The job qualifier, file name, and spooled file number are shown at the top of the Work with Spooled File Attributes screen.
          7 Use the following Copy Spooled File (CPYSPLF) command to copy the data from the spooled file to the physical file member:

          CPYSPLF FILE(spooled_file_name) JOB(number/user/job)
                  TOFILE(library/file_name) TOMBR(member_name)
                  MBROPT(*REPLACE)
          8 The spooled file has been copied to the physical file member without the First Character Form Control (FCFC) information.
          Once the spooled file has been copied to the physical file member, do all of the following:
          o Save it to media (for archives) or a save file
          o Restore it from media or a save file
          o Create a new spooled file
          o Create a new spooled file with different attributes
          o Create a new spooled file after modifying the database member
          o Create a PCFILE

          • - Saving the Spooled File to Media



            You can use the Save Object (SAVOBJ) command to save the physical file (which contains one or more spooled files) to media. For example, to save the physical file to tape or optical media, type the following OS/400 command:

            SAVOBJ OBJ(file_name) LIB(library) DEV(tape_or_optical_drive)
                   OBJTYPE(*FILE) DTACPR(*YES)

            To save the physical file to a save file, type the following OS/400 commands:

            CRTSAVF FILE(library/save_file_name) TEXT('Save File Description')

            SAVOBJ OBJ(file_name) LIB(library) DEV(*SAVF) OBJTYPE(*FILE)
                   SAVF(library/save_file_name) DTACPR(*YES)



          • - Restoring the Spooled File from Media



            You can use the Restore Object (RSTOBJ) command to restore the physical file (which contains one or more spooled files) from media. For example, to restore the physical file from tape or optical media, type the following OS/400 command:

            RSTOBJ OBJ(file_name) SAVLIB(library) DEV(tape_or_optical_drive) OBJTYPE(*FILE)

            To save the physical file to a save file, type the following OS/400 commands:

            RSTOBJ OBJ(file_name) SAVLIB(library) DEV(*SAVF) OBJTYPE(*FILE)
                   SAVF(library/save_file_name)



          • - Example 1: Creating a New Spooled File with Different Attributes



            To generate a new spooled file with different attributes, do the following:

            1 Create a physical file and copy the spooled file to the data base file using the instructions in the Copying a Spooled File to a Physical File Member with First Character Form Control (FCFC) Information section or in the Copying Several Spooled Files into a Single Physical File Member with First Character Form Control (FCFC) Information section above. This will copy the text of the spooled file as well as the First Character Form Control (FCFC) information, which is used to preserve the line and page breaks in the spooled file.
            2 Use the Override with Printer File (OVRPRTF) command to override the settings of your printer file, for example:

            OVRPRTF FILE(QSYSPRT) CTLCHAR(*FCFC) CHLVAL(*NORMAL)
                    OUTQ(library/outq) OVRSCOPE(*JOB)

            The File being overridden (FILE) parameter specifies the name of the printer file to be overridden, such as QSYSPRT or QPJOBLOG. This can also be set to *PRTF to override all printer files. In the above example, the QSYSPRT system-supplied printer file is being overridden; however, no specific settings are being overridden. The parameters that often need to be overridden include, but are not limited to, the following:

            Page size (PAGESIZE)
            Lines Per Inch (LPI)
            Characters Per Inch (CPI)
            Source drawer (DRAWER)
            Font identifier (FONT)
            Degree of page rotation (PAGRTT)
            Print quality (PRTQLTY)
            Print on both sides (DUPLEX)

            Note: The Override Printer File (OVRPRTF) command above has the control character (CTLCHAR) parameter set to *FCFC and the channel values (CHLVAL) parameter set to *NORMAL. This will cause the Copy File (CPYF) command to handle the First Character Form Control information in the physical file member using the normal rules. It is also recommended that the Override scope (OVRSCOPE) parameter be set to *JOB to ensure that the OVRPRTF command takes effect at ALL call levels in the job. Without this, the OVRPRTF command may not take effect at all which would result in losing all line and page breaks in the new spooled file.
            3 Use the following Copy File (CPYF) command to copy the physical file member to a new spooled file:

            CPYF FROMFILE(library/file_name) FROMMBR(member_name)
                 TOFILE(QSYSPRT)

            Note: This example specifies the QSYSPRT system-supplied printer file in the TOFILE parameter, but another printer file can be specifed, such as the printer file used for the original spooled file. Regardless, this should match the printer file overridden by the Override with Printer File (OVRPRTF) command, unless all printer files were overridden by specifying *PRTF.

            • - Example 2: Modifying the Physical File Member and Rewriting the Spooled File



              To modify the data from in a source physical file member and generate a new spooled file, do the following:

              1 Create a source physical file and copy the spooled file to the data base file using the instructions in the Copying a Spooled File to a Physical File Member with First Character Form Control (FCFC) Information section or in the Copying Several Spooled Files into a Single Physical File Member with First Character Form Control (FCFC) Information section above. This will copy the text of the spooled file as well as the First Character Form Control (FCFC) information, which is used to preserve the line and page breaks in the spooled file.

              Since the intent is to copy a spooled file, modify the data in the spooled file, and then copy it back to a new spooled file, a source physical file should be created using the Create Source Physical File (CRTSRCPF) command. That will allow the member to be edited using either the Start Source Entry Utility (STRSEU) or Work with Members Using PDM (WRKMBRPDM) commands.

              Look to see the value specified for the Width, then use one of the following CRTSRCPF commands to create a physical file to store the data from the spooled files. The source physical file should be created with a record length at least 13 columns greater than the page width to accommodate not only the First Character Form Control (FCFC) byte, but also the source sequence number (which contains 6 bytes) and the date (which contains 6 bytes) which exist on each line of text in the source physical file member. For example, if the page width is 132, use the following command to create a source physical file with a record length of 145:

              CRTSRCPF FILE(library/source_physical_file) RCDLEN(145)

              If the page width is 198 bytes, use the following command to create a source physical file with a record length of 211:

              CRTSRCPF FILE(library/source_physical_file) RCDLEN(211)
              2 Use the following Copy File (CPYF) command to copy the member from the physical file into the source physical file:

              CPYF FROMFILE(library/source_physical_file)
                   TOFILE(library/source_physical_file) FROMMBR(member_name)
                   TOMBR(source_member_name) MBROPT(*ADD) FMTOPT(*CVTSRC)

              Press the Enter key.

              Note: This is an example. Use the from/to files that you have created.
              3 You now have your spooled file in a source member that can be edited using the Start Source Entry Utility (STRSEU) or Work with Members Using PDM (WRKMBRPDM) commands. Edit or remove the text that you want. Note that the first column contains line data controls if using CTLCHAR(*FCFC) in the CPYSPLF command. Save the changes to the source physical file member.
              4 Use the following Copy File (CPYF) command to copy the source physical file member back into the physical file member:

              CPYF FROMFILE(library/source_physical_file) TOFILE(library/file_name)
                  FROMMBR(member_name) TOMBR(member_name) MBROPT(*REPLACE)
              5 Use the following Copy File (CPYF) command to copy the physical file member to a new spooled file:

              CPYF FROMFILE(library/file_name) FROMMBR(member_name)
                   TOFILE(QSYSPRT)

              • - Example 3: Copying the Data from a Spooled File to an ASCII Text File on a PC Using the CPYTOPCD Command



                To copy the data from a spooled file to an ASCII text file on a PC, do the following:

                1 Determine whether to save the spooled file with or without the First Character Form Control (FCFC) information. Then create a physical file and copy the spooled file to the data base file using the instructions in either the Copying a Spooled File to a Physical File Member with First Character Form Control (FCFC) Information section or the Copying a Spooled File to a Physical File Member without First Character Form Control (FCFC) Information section above.
                2 Use the following Copy to PC Document (CPYTOPCD) command to copy the physical file member to a document in a folder:

                CPYTOPCD FROMFILE(library/file_name) TOFLR(folder_name)
                         FROMMBR(member_name) TODOC(pc_file_name.TXT) TRNTBL(*DFT)
                         TRNFMT(*TEXT)
                3 Copy the ASCII text file to a PC running iSeries Access for Windows using the iSeries NetServer File Share support, or by using a mapped drive that points to the QDLS iSeries NetServer file share in the Integrated File System (IFS).

                The TCP/IP File Transfer Protocol (FTP) and Client Access file transfer functions can be used as an alternative. Both have the advantage of being able to copy the data from the spooled file without first copying it to a Shared Folder. For more information on using FTP, refer to Example 4: Copying the Data from a Spooled File to an ASCII Text File on a PC Using FTP or Example 5: Using FTP to Upload the Data from a PC Text File Back to an iSeries or AS/400 System Physical File below.

                Another alternative is to use the drag-and-drop function within the Basic Operations | Printer Output or Basic Operations | Printers containers within Operations Navigator.


              • - Example 4: Copying the Data from a Spooled File to an ASCII Text File on a PC Using FTP



                To copy the data from a spooled file to an ASCII text file on PC using FTP, do the following:

                1 Determine whether to save the spooled file with or without the First Character Form Control (FCFC) information. Then create a physical file and copy the spooled file to the data base file using the instructions in either the Copying a Spooled File to a Physical File Member with First Character Form Control (FCFC) Information section or the Copying a Spooled File to a Physical File Member without First Character Form Control (FCFC) Information section above.
                2 Go to an MS-DOS Prompt or Command Prompt and use the CD command to connect to the directory that you want to contain the ASCII text file.
                3 Type FTP <system_name> or FTP XXX.XXX.XXX.XXX to connect to the iSeries or AS/400 system.
                4 Type QUOTE SITE NAMEFMT 0 to change the iSeries or AS/400 System to use naming convention type 0
                5 Type CD <library> command to connect to the OS/400 library where the physical file member was created.
                6 If copying text from a secondary language, type QUOTE TYPE C <ascii_code_page> where <ascii_code_page> is the ASCII code page that corresponds to the secondary CCSID used to generate the spooled file. This will force the job to use the secondary CCSID when converting text. Otherwise, the primary CCSID specified on the IBM System i is assumed.

                Note: For more information on copying spooled files with a secondary CCSID, refer to the following KB document:

                N1019721: Data Transfer and CCSID 65535 Database Files
                7 Type GET  <file_name>.<member_name> <PC_file_name>.TXT to download the file to the PC.
                8 Type QUIT to disconnect from the iSeries or AS/400 System.
                9 Type EXIT to close the MS-DOS Prompt or Command Prompt.

                • - Example 5: Copying the Data from an ASCII Text File on a PC Back to an Operating System Spooled File Using FTP



                  To copy the data from an ASCII text file on a PC to a physical file member on an IBM System i system and then to a spooled file, do the following:

                  1 Use one of the following Create Physical File (CRTPF) commands to create a physical file to store the data from the spooled files. The command to be used depends on the page width specified in the spooled file attributes. If the page width is 132, use the following command to create a physical file with a record length of 133 bytes:

                  CRTPF library/file_name RCDLEN(133) MAXMBRS(*NOMAX)
                        SIZE(*NOMAX) LVLCHK(*NO)

                  If the page width is 198, use the following command to create a physical file with a record length of 199 bytes:

                  CRTPF library/file_name RCDLEN(199) MAXMBRS(*NOMAX)
                        SIZE(*NOMAX) LVLCHK(*NO)
                  2 Go to an MS-DOS Prompt or Command Prompt and use the CD command to connect to the directory that you want to contain the ASCII text file.
                  3 Type FTP <system_name> or FTP XXX.XXX.XXX.XXX to connect to the System i system.
                  4 Type QUOTE SITE NAMEFMT 0 to change the System i system to use naming convention type 0
                  5 Type CD <library> command to connect to the operating system library where the physical file was created.
                  6 Type ASCII to ensure that FTP is in ASCII text mode and not in BINARY mode.
                  7 Type PUT <PC_file_name>.TXT <file_name>.<member_name> command to upload the file from the PC to a physical file member on the IBM i System.
                  8 Type QUIT to disconnect from the System i system.
                  9 Type EXIT to close the MS-DOS Prompt or Command Prompt.
                  10 Use the Override with Printer File (OVRPRTF) command to override the settings of your printer file, for example:

                  OVRPRTF QSYSPRT CTLCHAR(*FCFC) CHLVAL(*NORMAL)
                          PAGRTT(0) OUTQ(library/outq) OVRSCOPE(*JOB)

                  This specific command overrides the QSYSPRT system-supplied printer file to set the Degree of page rotation (PAGRTT) parameter to 0. This will cause the new spooled file to print in portrait instead of landscape. The printer file used for the original spooled file can be used instead of QSYSPRT, or *PRTF can be specified to override all printer files. Also, other parameters besides PAGRTT can be overridden including, but not limited to, the following:

                  Page size (PAGESIZE)
                  Lines per Inch (LPI)
                  Characters per Inch (CPI)
                  Source drawer (DRAWER)
                  Font identifier (FONT)
                  Print quality (PRTQLTY)
                  Print on both sides (DUPLEX)

                  Note: The Override Printer File (OVRPRTF) command above includes not only the page rotation (PAGRTT) parameter, but also has the control character (CTLCHAR) parameter set to *FCFC and the channel values (CHLVAL) parameter set to *NORMAL. This will cause the Copy File (CPYF) command to handle the First Character Form Control information in the physical file member using the normal rules. It is also recommended that the Override scope (OVRSCOPE) parameter be set to *JOB to ensure that the OVRPRTF command takes effect at ALL call levels in the job. Without this, the OVRPRTF command may not take effect at all which would result in losing all line and page breaks in the new spooled file.
                  11 Use the following Copy File (CPYF) command to copy the physical file member to a new spooled file:

                  CPYF FROMFILE(library/file_name) FROMMBR(member_name)
                       TOFILE(QSYSPRT)

                  Note: This example specifies the QSYSPRT system-supplied printer file in the TOFILE parameter, but another printer file can be specifed, such as the printer file used for the original spooled file. Regardless, this should match the printer file overridden by the Override with Printer File (OVRPRTF) command, unless all printer files were overridden by specifying *PRTF.
                  Note: FTP can be used to copy the data from an ASCII text file on a PC directly to a printer file on an IBM System i system rather than first copying it to a physical file member. However, the data would be written to the spooled file by one of the QTFTPxxxxx jobs running on the system so the resulting spooled file would be generated using the default settings in the printer file (the settings could not be overridden using the OVRPRTF command). Also, the spooled file would be associated with the QPRTJOB job for the user profile.

                  • - Example 6: Copying the Data from a Spooled File to an ASCII Text File in the Integrated File System (IFS)



                    To copy the data from a spooled file to an ASCII Text File in a directory in the Integrated File System, do the following:

                    1 Determine whether to save the spooled file with or without the First Character Form Control (FCFC) information. Then, create a physical file and copy the spooled file to the data base file using the instructions in the Copying a Spooled File to a Physical File Member with First Character Form Control (FCFC) Information section or the Copying a Spooled File to a Physical File Member without First Character Form Control (FCFC) Information section above.
                    2a Use the following Copy Object (CPY) command to copy the physical file member to an ASCII Text File in a directory in the Integrated File System (IFS), for example:

                    CPY OBJ('/QSYS.LIB/library.LIB/file_name.FILE/member_name.MBR')
                        TOOBJ('/ifs_directory/pc_file_name.txt') FROMCCSID(*JOBCCSID)
                        TOCCSID(*PCASCII) DTAFMT(*TEXT) REPLACE(*YES)
                    2b As an alternative, you can use the Copy To Import File (CPYTOIMPF) command to copy the physical file member to an ASCII text file in a directory in the Integrated File System (IFS), for example:

                    CPYTOIMPF FROMFILE(library/file_name)
                              TOSTMF('/ifs_directory/pc_file_name.txt') MBROPT(*REPLACE)
                              RCDDLM(*CRLF) DTAFMT(*FIXED) STMFCODPAG(*PCASCII)
                    3 At this point, the ASCII text file can be copied to a PC running iSeries Access for Windows using the iSeries NetServer File Share support by using a mapped drive that points to the QDLS iSeries NetServer file share in the Integrated File System. Or, it can be made available to users through iSeries Access for Web or other application running within WebSphere.
                    The TCP/IP File Transfer Protocol (FTP) and Client Access file transfer functions can be used as an alternative. Both have the advantage of being able to copy the data from the spooled file without first copying it to a Shared Folder. For more information on using FTP, refer to Example 4: Copying the Data from a Spooled File to an ASCII Text File on a PC Using FTP or Example 5: Using FTP to Upload the Data from a PC Text File Back to an iSeries or AS/400 System Physical File below.

                    Another alternative is to use the drag-and-drop function within the Basic Operations | Printer Output or Basic Operations | Printers containers within Operations Navigator.

                    • - Example 7: Copying the Data from an ASCII Text File on a PC to a Physical File Member Using FTP



                      To copy the data from an ASCII text file on a PC to a physical file member on an IBM System i system, do the following:

                      1 Use one of the following Create Physical File (CRTPF) commands to create a physical file to store the data from the spooled files. The command to be used depends on the page width specified in the spooled file attributes. If the page width is 132, use the following command to create a physical file with a record length of 133 bytes:

                      CRTPF library/file_name RCDLEN(133) MAXMBRS(*NOMAX)
                            SIZE(*NOMAX) LVLCHK(*NO)

                      If the page width is 198, use the following command to create a physical file with a record length of 199 bytes:

                      CRTPF library/file_name RCDLEN(199) MAXMBRS(*NOMAX)
                            SIZE(*NOMAX) LVLCHK(*NO)
                      2 Go to an MS-DOS Prompt or Command Prompt and use the CD command to connect to the directory that already contains the ASCII text file.
                      3 Type FTP <system_name> or FTP XXX.XXX.XXX.XXX to connect to the System i system.
                      4 Type QUOTE SITE NAMEFMT 0 to change the System i system to use naming convention type 0
                      5 Type CD <library> command to connect to the operating system library where the physical file was created.
                      6 Type ASCII to ensure that FTP is in ASCII text mode and not in BINARY mode.
                      7 Type PUT <PC_file_name>.TXT <file_name>.<member_name> command to upload the file from the PC to a physical file member on the IBM i System.
                      8 Type QUIT to disconnect from the System i system.
                      9 Type EXIT to close the MS-DOS Prompt or Command Prompt.

                      • - Example 8: E-mailing the Data from a Spooled File Using the CPYTOPCD and SNDDST Commands



                        The Infoprint Server for iSeries product (5722IP1) can be used to convert *SCS and *AFPDS spooled files to Adobe Acrobat PDF format and to send them as e-mail, which uses Send Distribution (SNDDST) and SMTP under the covers. However, Infoprint Server requires a license key to use the product after an initial 70-day grace period.

                        The Copy Spooled File (CPYSPLF), Copy to PC Document (CPYTOPCD), and Send Distribution (SNDDST) commands can be used as an alternative to the Infoprint Server product to send the data from *SCS spooled files, not *AFPDS spooled files, using e-mail. Infoprint Server is a much more robust offering as it can convert both *SCS and *AFPDS spooled files to PDF instead of plain ASCII text, and since it can include overlays, page segments, bar codes, and fonts in the resulting PDF file, as well as extensive body text and attachments. However, this method can be used as a lower function, lower cost alternative.

                        To copy the data from a spooled file to an ASCII text file in a document in a folder and then to send that document as e-mail, do the following:

                        1 Determine whether to save the spooled file with or without the First Character Form Control (FCFC) information. Then create a physical file and copy the spooled file to the data base file using the instructions in either the Copying a Spooled File to a Physical File Member with First Character Form Control (FCFC) Information section or the Copying a Spooled File to a Physical File Member without First Character Form Control (FCFC) Information section above.
                        2 Use the Copy to PC Document (CPYTOPCD) command to copy the physical file member to a document in a folder, for example:

                        CPYTOPCD FROMFILE(library/file_name) TOFLR(folder_name)
                                 FROMMBR(member_name) TODOC(pc_file_name.TXT) TRNTBL(*DFT)
                                 TRNFMT(*TEXT)
                        3 The Document description (DOCD) parameter is used as the email subject line when a document is sent via email using the Send Distribution (SNDDST) command. The Copy to PC Document (CPYTOPCD) command sets the Document description (DOCD) parameter to the name of the document, so if you want to have a more useful subject line on the e-mail this parameter should be changed prior to running the SNDDST command.

                        The Change Document Description (CHGDOCD) command can be used to change the Document description (DOCD) parameter in the document that was just created using the CPYTOPCD command, for example:

                        CHGDOCD DOC(pc_file_name.TXT) FLR(folder_name)
                                DOCD('Sending report from System S10ABCDE')

                        For more information, refer to the following Rochester Support Center knowledgebase document:

                        N1019540: Using SNDDST TYPE(*FILE) or SNDDST TYPE(*DOC)
                        4 Use the Send Distribution (SNDDST) command to send the resulting document to an e-mail address, for example:

                        SNDDST TYPE(*DOC) TOINTNET((email@domain.com))
                               DSTD('Sending report from System S10ABCDE')
                               MSG('The report is contained in the attached TXT file.')
                               DOC(pc_file_name.TXT) FLR(folder_name)

                        Note: The IBM System i must be configured for Simple Mail Transfer Protocol (SMTP) in order to send documents to an e-mail address using the Send Distribution ( SNDDST) command. For more information on configuring SMTP, refer to the following Rochester Support Center knowledgebase documents:

                        N1017620: Configuring OS/400 SMTP

                        SNDDST and SMTP must also be configured in order to send e-mail using Infoprint Server, so if you have already configured SNDDST and SMTP when testing the Infoprint Server product during its 70-day grace period then they should already be configured to use the CPYSPLF, CPYTOPCD, and SNDDST commands to send the text from *SCS spooled files as an e-mail as well.

                      Historical Number

                      8013247

                      Rate this page:

                      (0 users)Average rating

                      Add comments

                      Document information


                      More support for:

                      IBM i
                      Print

                      Software version:

                      5.2.0, 5.3.0, 5.3.5, 5.4.0, 5.4.5, 6.1, 6.1.0, 6.1.1, 7.1, 7.1.0, 7.2, 7.2.0, Version Independent

                      Operating system(s):

                      IBM i

                      Reference #:

                      N1010238

                      Modified date:

                      2014-07-22

                      Translate my page

                      Machine Translation

                      Content navigation