Link to home
Start Free TrialLog in
Avatar of billymcqueary
billymcqueary

asked on

I need to find out the status (rdy, snd, hld, etc.) of a spool file from an as400 CL program

I need to find out when the status of the spool file created by this job has been printed and is in the SAV status. I'm not able continue in my program until the file has been printed. Any ideas? I'm using a DLYJOB now but I would like to continue right away once its at the SAV status.

Thanks.
Avatar of Member_2_276102
Member_2_276102

billymcqueary:

The Retrieve Spooled File Attributes (QUSRSPLA) API can return the status of a spooled file. When the Status is '*SAVED', you know you can continue.

Let me know if a sample of CL for this is needed.

Tom

Avatar of billymcqueary

ASKER

An example would be great if not too much to ask. Thanks.
ASKER CERTIFIED SOLUTION
Avatar of Barry Harper
Barry Harper
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Barry's example grabs a number of returned attributes for a spooled file and sends the values out as messages. The &STATUS variable is the one of most interest here; others that are extracted from the return variable can be eliminated. (But they're useful examples for cloned functions.)

The actual resulting function is pretty small.

Tom
The pruned version looks more like:
PGM ( +                                                                              
    &SPLFNAME  /* SPOOLED FILE NAME                      INPUT      */  +            
    )                                                                                
/* PARMS FOR API */                                                                  
DCL &RCVR     *CHAR    1500   /*RECEIVER VARIABLE                   */              
DCL &RCVRLEN  *CHAR       4   /*LENGTH OF RECEIVER VARIABLE         */              
DCL &RCVRFMT  *CHAR      10   /*FORMAT NAME                         */              
DCL &QUALJOB  *CHAR      26   /*QUALIFIED JOB NAME                  */              
DCL &INTJOB   *CHAR      16   /*INTERNAL JOB IDENTIFIER             */              
DCL &INTSPLF  *CHAR      16   /*INTERNAL SPOOLED FILE IDENTIFIER    */              
DCL &SPLFNAME *CHAR      10   /*SPOOLED FILE NAME                   */              
DCL &SPLNBR   *CHAR       4   /*SPOOLED FILE NUMBER                 */              
/* VALUES RETURNED BY API  */                                                        
DCL &STATUS   *CHAR      10   /* STATUS                             */              
             CHGVAR  &RCVRLEN    X'05DC'                                            
             CHGVAR  &RCVRFMT   'SPLA0100'                                          
             CHGVAR  &QUALJOB   '*                         '                        
             CHGVAR  &INTJOB    '                '                                  
             CHGVAR  &INTSPLF   '                '                                  
             CHGVAR  &SPLNBR    X'FFFFFFFF'                          
             CALL    QUSRSPLA   (&RCVR  &RCVRLEN &RCVRFMT +          
                                 &QUALJOB &INTJOB &INTSPLF +          
                                 &SPLFNAME &SPLNBR)                  
             CHGVAR  &STATUS    %SST(&RCVR  101  10)                  
             SNDPGMMSG ('STATUS >' || &STATUS   || '<')              
            ENDPGM                                                                

The possible values for &STATUS are:
*CLOSED The program completely processed the file, but SCHEDULE(*JOBEND) was specified, and the job that produced the file has not yet finished.
*DEFERRED The spooled file has been deferred from printing.
*SENDING The spooled file is being sent or has been sent to a remote system.
*HELD The file is held.
*MESSAGE The file has a message requiring a reply or an action.
*OPEN The file was not completely processed and is not ready for a writer.
*PENDING The file is pending to be printed.
*PRINTER The complete file was sent to the printer, but a print complete status was not sent back.
*READY The file is available to be written.
*SAVED The file was written and is saved. This file remains saved until it is released.
*WRITING The writer is writing the file on a diskette or a printer device.

To find more info on QUSRSPLA, search for QUSRSPLA (or use the API finder) at the IBM infocenter:
http://publib.boulder.ibm.com/infocenter/iseries/v5r3/index.jsp

Barry