Page 1 of 1

How do I find a spooled file created by the Exec400 Task?

Posted: Fri Mar 06, 2009 11:57 am
by Support_Duane
When running an exec400 (Execute System i Command or Program) task in GoAnywhere, the spool file job name and number are different from the job that is creating the spool file. IBM uses a job called QPRTJOB when the current job's user name is not the same as the current user profile.

A QPRTJOB job is a job that spooled files are associated with when the current job's user name is not the same as the user profile currently running. System jobs can change to run under a user's profile in order for a user to obtain ownership of the spooled file instead of the system job.

Here is a link explaining the issue from IBM
http://publib.boulder.ibm.com/infocente ... prtjob.htm

Here is one method and an example CL to show how to use it.
  • Create a Data Queue to keep info on the printout.
  • Create an Environment variable to point to the Data Queue.
  • Run your query.
  • Run the Receive Data Queue API (QRCVDTAQ) to read the info on the QPRTJOB job that runs the print.
  • Use the current user, the job name QPRTJOB and the job number returned from the Data Queue in your copy print files command.
Code: Select all
            PGM                                                       
                                                                      
            DCL        VAR(&DATAQUEUE) TYPE(*CHAR) LEN(10)            
            DCL        VAR(&LIB) TYPE(*CHAR) LEN(10)                  
            DCL        VAR(&LEN) TYPE(*DEC) LEN(5 0)                  
            DCL        VAR(&WAITTIME) TYPE(*DEC) LEN(5 0)             
            DCL        VAR(&DATA) TYPE(*CHAR) LEN(256)                
            DCL        VAR(&ENV) TYPE(*CHAR) LEN(128)                 
            DCL        VAR(&NBR) TYPE(*CHAR) LEN(6)                   
                                                                      
            CHGVAR     VAR(&LIB) VALUE('QTEMP')                       
            CHGVAR     VAR(&DATAQUEUE) VALUE('SPOOLQUEUE')            
            CHGVAR     VAR(&WAITTIME) VALUE(0)                        
            CHGVAR     VAR(&ENV) VALUE('*DTAQ ' *CAT &LIB *TCAT '/' + 
                         *CAT &DATAQUEUE)                             
                                                                      
            CRTDTAQ DTAQ(&LIB/&DATAQUEUE) MAXLEN(200) SEQ(*LIFO)      
              MONMSG     MSGID(CPF9870)                                 
                                                                     
            ADDENVVAR  ENVVAR(QIBM_NOTIFY_CRTSPLF) VALUE(&ENV) +     
                         LEVEL(*JOB)                                 
              MONMSG     MSGID(CPFA980) EXEC(CHGENVVAR +               
                           ENVVAR(QIBM_NOTIFY_CRTSPLF) VALUE(&ENV) +   
                           LEVEL(*JOB))                                
                                                                     
            DSPJOB     OUTPUT(*PRINT)                                
                                                                     
            CALL       PGM(QRCVDTAQ) PARM(&DATAQUEUE &LIB &LEN +     
                         &DATA &WAITTIME)                            
                                                                     
            SNDMSG     MSG(&DATA) TOUSR(RBYRD)                       
            CHGVAR     VAR(&NBR) VALUE(%SST(&DATA 33 6))             
                                                                     
            SNDMSG     MSG(&NBR) TOUSR(RBYRD)                        
                                                                     
@ENDPGM:    ENDPGM