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.
billymcquearyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

tliottaCommented:
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

0
billymcquearyAuthor Commented:
An example would be great if not too much to ask. Thanks.
0
_b_hCommented:
Here is some sample code to get you started. It retrieves more than the status, so you can see how some of the other parms work. If you would like a pruned version, let me know.

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                             */        
DCL &FORMTYPE *CHAR      10   /* FORM TYPE                          */        
DCL &USERDATA *CHAR      10   /* USER DATA                          */        
DCL &HOLD     *CHAR      10   /* HOLD BEFORE WRITING                */        
DCL &SAVE     *CHAR      10   /* SAVE AFTER WRITING                 */        
DCL &COPIESB  *CHAR       4   /* COPIES - BINARY                    */        
DCL &COPIESC  *CHAR       4   /* COPIES - CHARACTER                 */              
DCL &COPIESN  *DEC     (4 0)  /* COPIES - NUMERIC                   */              
DCL &PAGESB   *CHAR       4   /* PAGES  - BINARY                    */              
DCL &PAGESC   *CHAR       4   /* PAGES  - CHARACTER                 */              
DCL &PAGESN   *DEC     (4 0)  /* PAGES  - NUMERIC                   */              
DCL &LPIB     *CHAR       4   /* LINES PER INCH - BINARY - IN TENTHS*/              
DCL &LPIC     *CHAR       4   /* LINES PER INCH - CHARACTER         */              
DCL &LPIN     *DEC     (4 1)  /* LINES PER INCH - NUMERIC           */              
DCL &CPIB     *CHAR       4   /* CHARACTERS PER INCH - BINARY- IN TENTHS*/          
DCL &CPIC     *CHAR       4   /* CHARS PER INCH - CHARACTER             */          
DCL &CPIN     *DEC     (4 1)  /* CHARS PER INCH - NUMERIC               */          
DCL &OUTPTY   *CHAR       2   /* OUTPUT PRIORITY                        */          
             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  &FORMTYPE  %SST(&RCVR   81  10)                
            SNDPGMMSG ('FORMTYPE >' || &FORMTYPE || '<')          
            CHGVAR  &USERDATA  %SST(&RCVR   91  10)                
            SNDPGMMSG ('USERDATA >' || &USERDATA || '<')          
            CHGVAR  &STATUS    %SST(&RCVR  101  10)                
            SNDPGMMSG ('STATUS >' || &STATUS   || '<')            
            CHGVAR  &HOLD      %SST(&RCVR  121  10)                
            SNDPGMMSG ('HOLD >' || &HOLD || '<')                  
            CHGVAR  &SAVE      %SST(&RCVR  131  10)                
            SNDPGMMSG ('SAVE >' || &SAVE || '<')                  
            CHGVAR  &COPIESB   %SST(&RCVR  165   4)                
            CHGVAR  &COPIESC   %BINARY(&COPIESB)                  
            CHGVAR  &COPIESN   &COPIESC                            
            SNDPGMMSG ('COPY >' || &COPIESC || '<')                
            CHGVAR  &PAGESB   %SST(&RCVR  141   4)                
            CHGVAR  &PAGESC   %BINARY(&PAGESB)                    
            CHGVAR  &PAGESN   &PAGESC                              
            SNDPGMMSG ('PAGES >' || &PAGESC || '<')                
            CHGVAR  &LPIB      %SST(&RCVR  173   4)                
             CHGVAR  &LPIC      %BINARY(&LPIB)        
             CHGVAR  &LPIN      &LPIC                  
             SNDPGMMSG ('LPI >' || &LPIC || '<')      
             CHGVAR  &CPIB      %SST(&RCVR  177   4)  
             CHGVAR  &CPIC      %BINARY(&CPIB)        
             CHGVAR  &CPIN      &CPIC                  
             SNDPGMMSG ('CPI >' || &CPIC || '<')      
             CHGVAR  &OUTPTY    %SST(&RCVR  181   2)  
             SNDPGMMSG ('OUTPTY >' || &OUTPTY || '<')  
ENDPGM                                                

Please post back any questions!
Barry
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
tliottaCommented:
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
0
_b_hCommented:
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
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
IBM System i

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.