星期一, 11月 13, 2023

2023-11-13 Retrieve Current job last spooled file ID with API QSPRILSP


Retrieve Last Spooled file ID with API QSPRILSP
擷取 Job 最後產生的報表資訊 API QSPRILSP

pgm 
                                                  
   dcl   &SplfNbr1    *int    4
   dcl   &SplfNbr2    *int    4                   
                                                  
   dcl   &RcvVar        *char  70                   
   dcl     &BytesAvail  *int    4  stg(*defined) defvar(&RcvVar  1) 
   dcl     &BytesRtn    *int    4  stg(*defined) defvar(&RcvVar  5) 
   dcl     &SplfName    *char  10  stg(*defined) defvar(&RcvVar  9) 
   dcl     &JobName     *char  10  stg(*defined) defvar(&RcvVar 19) 
   dcl     &UserName    *char  10  stg(*defined) defvar(&RcvVar 29) 
   dcl     &JobNbr      *char   6  stg(*defined) defvar(&RcvVar 39) 
   dcl     &SplfNbr     *int    4  stg(*defined) defvar(&RcvVar 45) 
   dcl     &SysName     *char   8  stg(*defined) defvar(&RcvVar 49) 
   dcl     &SplfCrtDat  *char   7  stg(*defined) defvar(&RcvVar 57) 
   dcl     &SplfCrtTim  *char   6  stg(*defined) defvar(&RcvVar 65) 

   dcl   &RcvVarLen   *int    4    value(70)               
   dcl   &FmtName     *char  10                   
   dcl   &ErrorCode   *char   8                   
                                                  
   dcl   &Stat        *lgl                        
   dcl   &SplfExists  *lgl                        
                                                  

   callsubr subr(RtvSplfNbr) rtnval(&SplfNbr1)                   
   call     pgm1                                               
   callsubr subr(RtvSplfNbr) rtnval(&SplfNbr2)                   

/* If pgm1 created a report, continue with other tasks. */
   if (&SplfNbr2 *ne &SplfNbr1) do  
      call pgm2                             
      call pgm3                             
      call pgm4                             
   enddo                                     
   return                                    
       
subr subr(RtvSplfNbr) 
        
   chgvar   &BytesAvail         70 
   chgvar   &FmtName            'SPRL0100' 
   chgvar   &ErrorCode          x'0000000000000000' 
                                         
   chgvar   &SplfExists  '1'         
   call     QSPRILSP     (&RcvVar &RcvVarLen &FmtName &ErrorCode)  
   monmsg   cpf333a      exec(chgvar &SplfExists '0') 
   if (&SplfExists) then
   else do        
      chgvar   &SplfNbr        0    
   enddo                                
                                        
endsubr rtnval(&SplfNbr) 
                           
endpgm



Copy from https://www.itjungle.com/2006/02/08/fhg020806-story01/

沒有留言: