IBM Support

Finding and Working with Spooled Files Generated under a QPRTJOB Job

Troubleshooting


Problem

This document provides information on methods used to find spooled files generated under a QPRTJOB job.

Resolving The Problem

This document provides information on finding and working with spooled files generated under a QPRTJOB job.

This document was last updated on 7 November 2013.

Conditions When Spooled Files are Generated under a QPRTJOB Job

Spooled files are generated under a QPRTJOB job whenever the Set Profile Handle (QWTSETP, QsySetProfileHandle) API is used to generate spooled files for another user profile or whenever the spooled file is generated by a TCP/IP or Host Server Job and not by a user job running under the user profile. This includes the following scenarios:

oUsing the Set Profile Handle (QWTSETP, QsySetProfileHandle) in a user or third-party written program, utility, or application.
oGenerating output from a PC that is processed by one of a QZRCSRVS host server job; for example, using RUNRMTCMD, SQL or ADODB.
oGenerating output using Net.Data and possibly WebSphere and HTTP Server.
oCertain spooled files generated by Management Central.
oSpooled files generated by using a Remote Output Queue (RMTOUTQ) or the Send TCP/IP Spooled File (SNDTCPSPLF or LPR) command on one System i system to send a spooled file to another System i system or to another output queue on the same System i system.
oSpooled files generated by printing through an iSeries NetServer print share on a PC.
oSpooled files generated by using FTP to send a file to a printer file on the System i system.
oSpooled files generated by using LPR to print from a PC to a System i system.
There are different ways to find and work with spooled files that are generated when a job has swapped to another user profile and, therefore, are associated with a QPRTJOB job for that other user profile. These are discussed in the following sections in this document:
oUsing the QIBM_NOTIFY_CRTSPLF Environment Variable with a Data Queue
oUsing the Retrieve Identity of Last Spooled File Created (QSPRILSP) API
oMethods for Manually Finding and Working with QPRTJOB Spooled Files
    • - Using the QIBM_NOTIFY_CRTSPLF Environment Variable with a Data Queue



      If running V4R4M0 (R440) or V4R5M0 (R450) operating system, specific PTFs must be applied to use the QIBM_NOTIFY_CRTSPLF Environment Variable. If running V4R4M0 (R440) operating system, R440 PTF SF61082 or superseding PTF SF64657 should be applied. If running V4R5M0 (R450) operating system, then R450 PTF SF62350 or superseding PTF SF66903 should be applied. No PTFs are required to use the QIBM_NOTIFY_CRTSPLF Environment Variable in V5R1M0 (R510) operating system and above.

      The QIBM_NOTIFY_CRTSPLF environment variable can be used to associate a data queue with a specific job. Once this is set up, the job is notified when a new spooled file has been created under that job. Then, the Receive Data Queue (QRCVDTAQ) API can be used to receive the Record type 02 data queue entry, which includes the Qualified job name, Spooled file name, Spooled file number, Qualified output queue name, Creating qualified job name, User data, Auxiliary Storage Pool, Thread ID, System name, Creation date, and Creation time.

      Once a data queue entry is received, a user program can reference the spooled file by using the qualified job name, spooled file name, spooled file number, creation date, and creation time in several operating system commands including, but not limited to, the following:

      oChange Spooled File Attributes (CHGSPLFA)
      oCopy Spooled File (CPYSPLF)
      oDelete Spooled File (DLTSPLF)
      oHold Spooled File (HLDSPLF)
      oRelease Spooled File (RLSSPLF)
      oSend TCP/IP Spooled File (SNDTCPSPLF)

      Environment Variable Data Queue Support

      Using the Add Environment Variable (ADDENVVAR) or Change Environment Variable (CHGENVVAR) command, you can associate a data queue with a job or the system. As spooled files are created, the entries are logged in the data queue. Using the Receive Data Queue (QRCVDTAQ) API to receive information from the data queue, a user program can determine when a spooled file is created by the job or by the system. Use the environment variable data queue support to determine the identity of a spooled file that was stored under a QPRTJOB and was created by a job (such as a remote command system job).

      Using the CL command ADDENVVAR and specifying a fully qualified data queue name for the environment variable QIBM_NOTIFY_CRTSPLF you can associate a data queue with a job or the system. The command used is as follows:

      ADDENVVAR ENVVAR(QIBM_NOTIFY_CRTSPLF)
                VALUE('*DTAQ <library name>/<data queue name>')
                LEVEL(*JOB | *sys)

      The data queue must be created with a record length of at least 144 bytes. The data queue must also have a public authority of *USE, or grant the QSPL user profile *USE private authority to the data queue. You must ensure that the containing library has a public authority of *EXECUTE, or grant the QSPL user profile *EXECUTE private authority to the library. The format of the CRTDTAQ command is:

      CRTDTAQ DTAQ (<library name>/<data queue name>) MAXLEN(144) AUT(*USE)

      Once a data queue is associated with a job or the system, any spooled file created by the job or system will automatically have an entry placed in the data queue. For this action to occur, the user or user profile QSPL must have authorization to the data queue.

      Note: An environment variable that is specified at the job level takes precedence over the same environment variable specified at the system level.

      The entry in the data queue has a format of record type 02. See Record type 02 data queue entry format for a description of the information contained in record type 02.

      Record type 02 data queue entry format

      The data queue entry placed in the data queue specified in the environment variable QIBM_NOTIFY_CRTSPLF has the following format:

      Decimal
      Offset
      Hex
      Offset
      TypeLengthDescription
      00CHAR10Function
      Identifies the function that created the data queue entry. The value for a spooled file is *SPOOL.
      10ACHAR2Record type
      Identifies the record type within the function. Valid values are:
      02 A Spooled file has been created and placed on an output queue.
      12CCHAR26Qualified job name
      Identifies the qualified job name of the job that the spooled file is stored under.
      CHAR(10) Job name
      CHAR(10) User name
      CHAR(6) Job number
      3826CHAR10Spooled file name
      Identifies the name of the spooled file placed on the output queue.
      4830BINARY4Spooled file number
      Identifies the unique number of the spooled file placed on the output queue.
      5234CHAR20Qualified output queue name
      Identifies the qualified name of the output queue on which the spooled file was placed.
      CHAR(10) Output queue name
      CHAR(10) Output queue library
      7248CHAR26Creating qualified job name
      Identifies the qualified job name of the job that created the spooled file.
      CHAR(10) Job name
      CHAR(10) User name
      CHAR(6) Job number
      9862CHAR10User data
      Identifies the user specified data for the spooled file that was created.
      1086CBINARY4Auxiliary storage pool
      Identifies the auxiliary storage pool the spooled file resides on.
      11270CHAR8Thread identifier
      Identifies the thread of the job that created the spooled file.
      12078CHAR10Reserved
      13082CHAR7Creation date
      Identifies the date on which the spooled file was created. The date is in format CYYMMDD.
      13789CHAR6Creation time
      Identifies the time on which the spooled file was created. The time is in format HHMMSS.
      143BFCHAR1Reserved

      Example

      The following is an example that provides an overview of how to use the QIBM_NOTIFY_CRTSPLF environment variable to find and process spooled files created within the current job while it is swapped to another user profile:
        1.
      Use the Create Data Queue (CRTDTAQ) command to create a data queue to be updated whenever a spooled file has been created in the current job. For example:

      CRTDTAQ DTAQ (<library name>/<data queue name>) MAXLEN(144) AUT(*USE)

      Note: The data queue must be created with a record length of at least 144 bytes. The data queue must also have a public authority of *USE, or grant the QSPL user profile *USE private authority to the data queue. You must ensure that the containing library has a public authority of *EXECUTE, or grant the QSPL user profile *EXECUTE private authority to the library.
        2.
      Use the Add Environment Variable (ADDENVVAR) command to assign the QIBM_NOTIFY_CRTSPLF environment variable to point to the data queue that was just created. For example:

      ADDENVVAR ENVVAR(QIBM_NOTIFY_CRTSPLF)
                VALUE('*DTAQ <library name>/<data queue name>')
                LEVEL(*JOB | *sys)
        3.
      Swap to the other user profile.
        4.
      Generate a spooled file.
        5.
      Use the Receive Data Queue (QRCVDTAQ) API to determine the qualified job name, spooled file name, spooled file number, creation date and creation time for the spooled file created in Step 4.
        6.
      Process the spooled file by using the qualified job name, spooled file name, spooled file number, creation date and creation time received from the data queue entry.
        7.
      Repeat Steps 3 through 6 as necessary.

      For More Information

      For more information, refer to the following topics in the IBM i Information Center.

      System i: Data Queue Support:
      7.1http://publib.boulder.ibm.com/infocenter/iseries/v7r1m0/index.jsp?topic=/rzalu/rzaludataq.htm
      6.1http://publib.boulder.ibm.com/infocenter/iseries/v6r1m0/index.jsp?topic=/rzalu/rzaludataq.htm
      5.4http://publib.boulder.ibm.com/infocenter/iseries/v5r4/topic/rzalu/rzaludataq.htm

      Record type 02 data queue entry format
      7.1http://publib.boulder.ibm.com/infocenter/iseries/v7r1m0/index.jsp?topic=/rzalu/rzalurectype02.htm
      6.1http://publib.boulder.ibm.com/infocenter/iseries/v6r1m0/topic/rzalu/rzalurectype02.htm
      5.4http://publib.boulder.ibm.com/infocenter/iseries/v5r4/topic/rzalu/rzalurectype02.htm

      Receive Data Queue (QRCVDTAQ) API
      7.1http://publib.boulder.ibm.com/infocenter/iseries/v7r1m0/topic/apis/qrcvdtaq.htm
      6.1http://publib.boulder.ibm.com/infocenter/iseries/v6r1m0/topic/apis/qrcvdtaq.htm
      5.4http://publib.boulder.ibm.com/infocenter/iseries/v5r4/topic/apis/qrcvdtaq.htm

      • - Using the Retrieve Identity of Last Spooled File Created (QSPRILSP) API



        If running V5R2M0 (R520) operating system or above, the Retrieve Identity of Last Spooled File Created (QSPRILSP) API can be used to retrieve information on the last spooled file created by the current job. The QSPRILSP API returns this information in the receiver variable using the SPRL0100 format, which includes the Bytes returned, Bytes available, Spooled file name, Job name, User name, Job number, Spooled file number, Job system name, Spooled file create date, and Spooled file create time.

        Once the QSPRILSP API has retrieved information on the last spooled file created, a user program can reference the spooled file by using the spooled file name, job name, user name, job number, spooled file number, job system name, spooled file create date and spooled file create time in several operating system commands including, but not limited to, the following:

        oChange Spooled File Attributes (CHGSPLFA)
        oCopy Spooled File (CPYSPLF)
        oDelete Spooled File (DLTSPLF)
        oHold Spooled File (HLDSPLF)
        oRelease Spooled File (RLSSPLF)
        oSend TCP/IP Spooled File (SNDTCPSPLF)
        Note: If a prestart job entry has the Maximum number of uses (MAXUSE) parameter set to a value greater than 1 (the default for the QZDASOINIT prestart job entry), the QSPRILSP API could potentially pick up a spooled file generated on the previous use of the job if that happens to be the last spooled file generated. A sample CL program, SPLFODBC2, is contained in the splfodbc.zip file Rochester Support Center knowledgebase document New, Retrieving Spooled Files Generated in a Host Server Job. To link to document New immediately, click here .

        Format of Receiver Variable

        The following table describes the order and format of the data that the Retrieve Identity of Last Spooled File Created (QSPRILSP) API returns in the receiver variable:

        SPRL0100 Format
        Decimal
        Offset
        Hex
        Offset
        TypeLengthDescription
        00BINARY4Bytes returned
        Identifies the function that created the data queue entry. The value for a spooled file is *SPOOL.
        44BINARY4Bytes available
        The number of bytes of data available to be returned. All available data is returned if enough space is provided.
        88CHAR10Spooled file name
        The name of the last spooled file created by the current job or thread.
        1812CHAR10Job name
        The name of the job that owns the spooled file.
        281CCHAR10User name
        The name of the user who owns the last spooled file created by the current job or thread.
        3826CHAR6Job number
        The number of the job that owns the spooled file.
        442CBINARY4Spooled file number
        The number of the last spooled file created by the current job or thread.
        4830CHAR8Job system name
        The name of the system where the job that created the spooled file ran.
        5638CHAR7Spooled file create date
        The date the spooled file was created on the system. The date is in the CYYMMDD format as follows:
        C Century, where 0 indicates years 19xx and 1 indicates years 20xx.
        YY Year
        MM Month
        DD Day
        633FCHAR1Reserved
        6440CHAR6Spooled file create time
        The time the spooled file was created on the system. The time is in the HHMMSS format where:
        HH Hour
        MM Minutes
        SS Seconds

        Example

        The following is an example that provides an overview of how to use the Retrieve Identity of Last Spooled File Created (QSPRILSP) API to find and process spooled files created within the current job while it is swapped to another user profile:
        1.Swap to the other user profile.
        2.Generate a spooled file.
        3.Use the Retrieve Identity of Last Spooled File Created (QSPRILSP) API to determine the spooled file name, job name, user name, job number, spooled file number, job system name, spooled file create date, and spooled file create time for the spooled file created in Step 2.
        4.Process the spooled file by using the spooled file name, job name, user name, job number, spooled file number, job system name, spooled file create date and spooled file create time retrieved by the QSPRILSP API
        5.Repeat Steps 1 through 4, as necessary.

        For More Information

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

        N1017490: Retrieving Spooled Files Generated in a Host Server Job

        and the following topic within the IBM i Information Center:

        Retrieve Identity of Last Spooled File Created (QSPRILSP) API
        7.1http://publib.boulder.ibm.com/infocenter/iseries/v7r1m0/topic/apis/QSPRILSP.htm
        6.1http://publib.boulder.ibm.com/infocenter/iseries/v6r1m0/topic/apis/QSPRILSP.htm
        5.4http://publib.boulder.ibm.com/infocenter/iseries/v5r4/topic/apis/QSPRILSP.htm

        • - Methods for Manually Finding and Working with QPRTJOB Spooled Files


          oWork with User Jobs (WRKUSRJOB) command, select Option 5 (Work with) on the QPRTJOB job that is in the list. Then, select Option 4 (Work with spooled files) to work with the spooled files associated with that QPRTJOB job.
          oUse the Work with Job (WRKJOB) command, specify "QPRTJOB" for the job name, and specify the job user name. Leave the job number blank, for example:

          WRKJOB JOB(user-profile/QPRTJOB)

          If there is more than one QPRTJOB job associated with the user profile, this command typically brings up the Select Job screen where the job can be selected using Option 1. Otherwise, this command will take you directly to the Work with Job screen for that specific job, so you can then select Option 4 (Work with spooled files) to work with the spooled files associated with that QPRTJOB job.

          Note: The Work with Job (WRKJOB) command can be used with the Option (OPTION) parameter set to *SPLF to take you directly to the Work with Job Spooled Files screen without having to first select Option 4 (Work with spooled files). For example:

          WRKJOB JOB(user-profile/QPRTJOB) OPTION(*SPLF)
          oYou can work with spooled files on the system using iSeries Navigator by going into Basic Operations > Printer Output. Pressing the F11 key, or selecting View > Customize this View > Include, brings up the "Printer Output - Include" dialog box, that will let you specify which printer output to display in the list. This dialog lets you specify the job name. Therefore, you can set the job name to "QPRTJOB" and specify the job user name. However, the job number must also be specified.

          Note: Pressing the F12 key, or selecting View > Customize this View > Columns brings up the "Printer Output - Columns" dialog box that lets you specify which columns of information you want to display in the list. If the Job Name column is added to the list, you can scan the list of spooled files looking for a job name of "QPRTJOB" to find the spooled file.

        [{"Product":{"code":"SWG60","label":"IBM i"},"Business Unit":{"code":"BU054","label":"Systems w\/TPS"},"Component":"Print","Platform":[{"code":"PF012","label":"IBM i"}],"Version":"5.4.5;6.1;6.1.1;7.1;5.1.0;5.2.0;5.3.0;5.3.5;5.4.0;5.4.5;6.1.0;6.1.1;7.1.0","Edition":"","Line of Business":{"code":"LOB08","label":"Cognitive Systems"}},{"Product":{"code":"SSC3X7","label":"IBM i 6.1"},"Business Unit":{"code":"BU054","label":"Systems w\/TPS"},"Component":" ","Platform":[{"code":"","label":null}],"Version":"","Edition":"","Line of Business":{"code":"","label":""}},{"Product":{"code":"SSC52E","label":"IBM i 7.1"},"Business Unit":{"code":"BU054","label":"Systems w\/TPS"},"Component":" ","Platform":[{"code":"","label":null}],"Version":"","Edition":"","Line of Business":{"code":"","label":""}}]

        Historical Number

        409840299

        Document Information

        Modified date:
        18 December 2019

        UID

        nas8N1019015