AS400: RPGLE - Get the job attribute and Trap Error using Monitor

This program will check if a job is active, If active it will give the status of the job.

D eFlag             S              1       
DQusrJobi         PR                  EXTPGM('QUSRJOBI')   
DRcvVar                      32766A   options(*varsize)     
DRcvVarLen                      10I 0 const                 
DFormat                             8A   const                 
DQualJob                          26A   const                 
DInternJob                        16A   const                 
D vQualjob        DS               
D  Vjob                            10 
D  vUser                          10 
D  vjNbr                            6 
Ddsjob              ds               
D jobvar                   1     50 
D jobStat                51     60 
D JobAStat           108    111 
D                     sds               
D MsgId                  40     46 
D ExceptData         91    170 

/Free
   vJob = 'RBCPTY1Q01';                                               
 vUser = 'RBTUSERX';                                               
 vJnbr = '823061';                                                 
 Monitor;                                                           
 callp Qusrjobi(dsjob:%size(dsjob):'JOBI0200':vQualjob:*blanks);   
 On-Error;                                                         
  If MsgId = 'CPF3C53';                                             
   EFlag = 'Y';                                                     
  EndIf;                                                           
 EndMon;                                                           
 return;                                                           
/End-Free             


If the job is not active (CPF3C53) the program will go to On-Error  and set the eFlag. If active the status of the job in JobAStat Like (MSGW, RUN, etc). jobStat will be *ACTIVE, JOBQ etc of active
                                       

Comments

Popular posts from this blog

AS400 : Add a new line in text in email SNDSMTPEMM

AS400 Display: Radio Button (SNGCHCFLD)

AS400 Display File: Check Box (MLTCHCFLD)