?
Solved

How can I determine if a Job is not active from withing an ILE-RPG program?

Posted on 2009-02-09
9
Medium Priority
?
1,249 Views
Last Modified: 2012-05-06
I have stored the (job number, name, and user) of particular jobs in a PF. I need to be able to know if one of the (job number,name,user) entries stored in the physical file are not active when the record is read. I need this answer really fast please. Phil
0
Comment
Question by:Phillip Knox
  • 5
  • 3
9 Comments
 
LVL 14

Accepted Solution

by:
daveslater earned 2000 total points
ID: 23590876
Hi use the folloing API
here is an example
The status is in field status in the Jobi0100  data structure


D Job             s             10    
D User            s             10    
D Jobnbr          s              6    
D Qusrjobi        Pr                  ExtPgm('QUSRJOBI')              
D  P_Receiver                         Like(Jobi0100)                  
D  P_Reclen                           Like(Reclen)    Const           
D  P_Format                           Like(Format)    Const           
D  P_Job                              Like(Fulljob)   Const           
D  P_Ijob                             Like(Ijob)      Const           
D  P_Error                            Like(Errords)   Const           
D Jobi0100        Ds                                                                  
D  Intjobid                     16    Overlay(Jobi0100:35)                            
D  Status                       10    Overlay(Jobi0100:51)                            
D                                                                                     
D Reclen          S             10I 0 Inz(%Size(Jobi0100))                            
D Format          S              8    Inz('JOBI0100')                                 
D Fulljob         S             26                                                    
D Ijob            S             16                                                    
                                                                                      
C                   Reset                   Jobi0100                                  
C                   Reset                   Errords                                   
                                                                                      
C                   Eval      Fulljob = Job + User + Jobnbr                           
C                   Callp     Qusrjobi(Jobi0100                                       
C                                      : Reclen                                       
C                                      : Format                                       
C                                      : Fulljob                                      
C                                      : Ijob                                         
C                                      : Errords)       

Open in new window

0
 
LVL 4

Expert Comment

by:LewisPower
ID: 23590897
Hi Phil,

If you already have all the information (job number, name, and user), you can just do a DSPJOB  with JOB parameter filled and enter *STSA in option parameter. First line on the screen is the job status...

Is that what you're looking for ?

Lewis
0
 
LVL 14

Expert Comment

by:daveslater
ID: 23590907
my error ds is
 D ErrorDS         ds                  Qualified Inz                    
 D   BytesProv                   10i 0 inz(%size(ErrorDS))              
 D   BytesAvail                  10i 0                                  
 D   MsgId                        7                                    
 D   Spare                        1                                    
 D   text                        52                                    
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 

Author Comment

by:Phillip Knox
ID: 23591186
Dave,
What am I looking for in errorDS?
0
 
LVL 14

Expert Comment

by:daveslater
ID: 23591193
here is what the output looks like

EVAL Jobi0100                          
INTJOBID OF JOBI0100 = ' Ï   °ï´o;´
STATUS OF JOBI0100 = '*ACTIVE   '      

EVAL Errords                          
ERRORDS.BYTESPROV = 68                
ERRORDS.BYTESAVAIL = 0                
ERRORDS.MSGID = '       '              
ERRORDS.SPARE = ' '                    
ERRORDS.TEXT = '                      


Ps I have just updated the Program to change the job etc from a parm to a variable

Dave
0
 
LVL 14

Expert Comment

by:daveslater
ID: 23591237
error ds is needed for the api

here is a full working priogram  - the job INZ for the job is my job number

H                                                                                  
D ErrorDS         ds                  Qualified Inz                                
D   BytesProv                   10i 0 inz(%size(ErrorDS))                          
D   BytesAvail                  10i 0                                              
D   MsgId                        7                                                 
D   Spare                        1                                                 
D   text                        52                                                 
D                                                                                  
D Job             s             10     Inz('SDSA1')                                
D xUser           s             10     Inz('DAVIDS')                               
D Jobnbr          s              6     Inz('192282')                               
D Qusrjobi        Pr                  ExtPgm('QUSRJOBI')                           
D  P_Receiver                         Like(Jobi0100)                               
D  P_Reclen                           Like(Reclen)    Const                        
D  P_Format                           Like(Format)    Const                        
D  P_Job                              Like(Fulljob)   Const                        
D  P_Ijob                             Like(Ijob)      Const                        
D  P_Error                            Like(Errords)   Const                        
D Jobi0100        Ds                                                               
D  Intjobid                     16    Overlay(Jobi0100:35)                      
D  Status                       10    Overlay(Jobi0100:51)                      
                                                                                
D                                                                               
D Reclen          S             10I 0 Inz(%Size(Jobi0100))                      
D Format          S              8    Inz('JOBI0100')                           
D Fulljob         S             26                                              
D Ijob            S             16                                              
                                                                                
C                   Reset                   Jobi0100                            
C                   Reset                   Errords                             
 
 ** use your datbase fields here to make 
                                                                                
C                   Eval      Fulljob = Job + xUser + Jobnbr                    
C                   Callp     Qusrjobi(Jobi0100                                 
C                                      : Reclen                                 
C                                      : Format                                 
C                                      : Fulljob                                
C                                      : Ijob                                   
C                                      : Errords)                               
c                   Eval      *inlr = *on                     
C                   return                                    

Open in new window

0
 

Author Comment

by:Phillip Knox
ID: 23591256
It looks like I just need to see if 'STATUS OF JOBI0100' is = to *ACTIVE, right?

0
 
LVL 14

Expert Comment

by:daveslater
ID: 23591278
Yep, but if the job is inactive you need to check the errords
Message ID       Error Message Text
CPF24B4 E       Severe error while addressing parameter list.
CPF3CF1 E       Error code parameter not valid.
CPF3CF2 E       Error(s) occurred during running of &1 API.
CPF3C19 E       Error occurred with receiver variable specified.
CPF3C20 E       Error found by program &1.
CPF3C21 E       Format name &1 is not valid.
CPF3C24 E       Length of the receiver variable is not valid.
CPF3C36 E       Number of parameters, &1, entered for this API was not valid.
CPF3C51 E       Internal job identifier not valid.
CPF3C52 E       Internal job identifier no longer valid.
CPF3C53 E       Job &3/&2/&1 not found.
CPF3C54 E       Job &3/&2/&1 currently not available.
CPF3C55 E       Job &3/&2/&1 does not exist.
CPF3C57 E       Not authorized to retrieve job information.
CPF3C58 E       Job name specified is not valid.
CPF3C59 E       Internal identifier is not blanks and job name is not *INT.
CPF3C90 E       Literal value cannot be changed.
CPF9820 E       Not authorized to use library &1.
CPF9872 E       Program or service program &1 in library &2 ended. Reason code &3.

Dave
0
 

Author Closing Comment

by:Phillip Knox
ID: 31544497
Excellent. Thanks, Dave
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A question that many companies need to answer until May 25th of 2018... Is your company ready for GDPR?
An ASP.NET Web Form User Control is not newly introduced in ASP.NET. In fact, it was an old technology yet still playing a role to generate web content, especially when we want to use it to have a better and easy way to control part of the web conte…
How to fix display issue, screen flickering issue when I plug in power cord to the machine. Before I start explaining the solution lets check out once the issue how it looks like after I connect the power cord. most of you also have faced this…
Get the source code for a fully functional Access application shell with several popular security features that Access VBA application developers desire, but find difficult or impossible to figure out how to code. You get the source code for managi…
Suggested Courses

601 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question