Check status of jobs in REXX



JES, JES2, JCL utilities, IDCAMS, Compile & Run JCLs, PROCs etc...

Check status of jobs in REXX

Postby crazydoc » Thu Jun 16, 2016 7:14 pm

Good day. Is it possible to check the status of the job and its RC, if the job is running from REXX? The return of these values to the job runs the REXX(in a neighboring topics I asked for help and gave an example of how to solve the problem, for it and designed this task)? So far I've made an example in REXX(only to check the status, separately running task)):
/******************************** REXX *****************************/
STRING = 'IKJ56192I JOB EXAMPLE(JOB00578) ON OUTPUT QUEUE'                                                            
DO TIME=1 TO 10 UNTIL (Y = STRING)                                
ADDRESS TSO                                                          
X = OUTTRAP('LOG.')                                                  
"TSO STATUS EXAMPLE"                                                
X = OUTTRAP('OFF')                                                  
Y = LOG.1                                                            
CALL SYSCALLS('ON')                          
ADDRESS SYSCALL                                                      
"SLEEP" 1                            
CALL SYSCALLS 'OFF'                                                  
SAY ''TIME' Y='LOG.1                                                
END                                                                  
SAY 'END'                                                            

But it might not be the best option. Can anyone advise better?
crazydoc
 
Posts: 50
Joined: Fri Jul 24, 2015 12:27 pm
Has thanked: 2 times
Been thanked: 0 time

Re: Check status of jobs in REXX

Postby Akatsukami » Thu Jun 16, 2016 9:24 pm

Note that this will lock your terminal until the job completes and is placed on the on the output queue, which may be never! Why is using the NOTIFY keyword on the job card considered inadequate?
"You have sat too long for any good you have been doing lately ... Depart, I say; and let us have done with you. In the name of God, go!" -- what I say to a junior programmer at least once a day
User avatar
Akatsukami
Global moderator
 
Posts: 1058
Joined: Sat Oct 16, 2010 2:31 am
Location: Bloomington, IL
Has thanked: 6 times
Been thanked: 51 times

Re: Check status of jobs in REXX

Postby willy jensen » Thu Jun 16, 2016 9:44 pm

I would strongly advise using the REXX/SDSF API described in the SDSF manual. As to the never-ending case, check the status a number of times, then ask the user if (s)he wants to continue checking.
willy jensen
 
Posts: 455
Joined: Thu Mar 10, 2016 5:03 pm
Has thanked: 0 time
Been thanked: 69 times

Re: Check status of jobs in REXX

Postby crazydoc » Fri Jun 17, 2016 12:17 pm

Akatsukami wrote:Note that this will lock your terminal until the job completes

Indeed, it is this problem is. Use NOTIFY?
Can't figure out how to use it... Perhaps you should explain all the steps:
1) In JCL (No. 1), has consistently run a couple of REXX.
2) REXX job changes(changes of the variables in the SYSIN DD) to the other, pre-prepared JCL (No. 2).
The main problem is the first step runs faster than the REXX ends JCL (No. 2), which in turn, when the simultaneous implementation of conflict for resources.
It is necessary to JCL (No. 1) waiting for the completion of work modified JCL (No. 2), before starting the next step with REXX - I don't know how to do it. Or that REXX was expecting the end of the modified JCL (No. 2), which causes a problem of blocking of the terminal.
crazydoc
 
Posts: 50
Joined: Fri Jul 24, 2015 12:27 pm
Has thanked: 2 times
Been thanked: 0 time

Re: Check status of jobs in REXX

Postby crazydoc » Fri Jun 17, 2016 12:21 pm

willy jensen wrote:I would strongly advise using the REXX/SDSF API described in the SDSF manual.

Found the book: http://www.redbooks.ibm.com/redbooks/pdfs/sg247419.pdf
But the deal quickly fail. Could you suggest what key words to look for? What tools can help solve this problem?
crazydoc
 
Posts: 50
Joined: Fri Jul 24, 2015 12:27 pm
Has thanked: 2 times
Been thanked: 0 time

Re: Check status of jobs in REXX

Postby Aki88 » Fri Jun 17, 2016 1:29 pm

NOTIFY is a JCL keyword which requests system to send a message to a user (user here can mean a mainframe user ID) when the job completes processing.
It is coded on the job card in a JCL.

Syntax is a simple- NOTIFY=<user id here>

PS: It is independent of a program (REXX or otherwise); it is a JCL parameter, meaning if you have a job/JCL which you are submitting - then this can be coded on it.

Look at MVS JCL Reference for your z/OS release for more information on this keyword.
Aki88
 
Posts: 381
Joined: Tue Jan 28, 2014 1:52 pm
Has thanked: 33 times
Been thanked: 36 times

Re: Check status of jobs in REXX

Postby crazydoc » Fri Jun 17, 2016 2:23 pm

Thanks for the help. In several practical experiments, it was found that running REXX from JCL does not block the terminal at run time.
What I got:
1) JCL(No.1) REXX runs:
//REXXJOB  JOB  MSGLEVEL=(1,1),MSGCLASS=A,CLASS=A,REGION=0M
//S1 EXEC PGM=IKJEFT01,REGION=0M,                          
//  PARM='REXXEXAM'        
//SYSEXEC  DD DISP=SHR,DSN=xxxx.xxx.xxx                    
//SYSTSPRT DD SYSOUT=*                                    
//SYSTSIN  DD DUMMY                                        
//CARDS DD DSN=xxxx.xxx.xxx(xxxxxx),                    
// DISP=SHR,UNIT=SYSDA,VOL=SER=xxxxxx                      

(Here dopoledne lines are not important are left - overs from other jobs)
2) REXX(in the original first changing the control card JCL No. 2) starts a simple task in which a single step is the expectation(simulation performance), and waits for the job to finish(checking every 10 seconds):
/******************************** REXX *****************************/
DSNA = "'BELV.PRC.JCL(EXAMPLE)'"                                    
ADDRESS TSO                                                          
X = OUTTRAP('LOG.')                                                  
"SUB "DSNA                                                          
X = OUTTRAP('OFF')                                                  
PARSE VAR LOG.1 "JOB" JOBNAME "("JOBID")" MESSAGE                    
ADDRESS TSO                                                          
X = OUTTRAP('LOG.')                                                  
"TSO STATUS "JOBNAME"("JOBID")"                                      
X = OUTTRAP('OFF')                                                  
Y = LOG.1                                                            
PASSWORD = Y                                                        
Z = 0                                                                
DO UNTIL Z \= PASSWORD                                              
ADDRESS TSO                                                          
X = OUTTRAP('LOG.')                                                  
"TSO STATUS "JOBNAME"("JOBID")"                                      
X = OUTTRAP('OFF')                                                  
Z = LOG.1                                                            
CALL SYSCALLS('ON')    /*ENABLE USS-CALLS*/                          
ADDRESS SYSCALL                                                      
"SLEEP" 10               /*SLEEP FOR ?? SECONDS*/                    
CALL SYSCALLS 'OFF'                                                  
TIME = TIME +1                                                      
END                                                                  


In the end, if the JCL No. 1 with the start REXX, the next step will be to wait for the end JCL No. 2(which starts in REXX).
(requires clarification - this example was run on the test machine, which almost does not feel pressure. if you are going to use it, pay attention to the process of assigning values to the variable PASSWORD)
Maybe it will help someone.
Also would be happy to explore options with SDSF API, if anyone can suggest what to look for from the tools API.
crazydoc
 
Posts: 50
Joined: Fri Jul 24, 2015 12:27 pm
Has thanked: 2 times
Been thanked: 0 time

Re: Check status of jobs in REXX

Postby NicC » Fri Jun 17, 2016 3:29 pm

You cannot have:
1 - job 1 starts
2 - job 2 starts
3 - job1 waits for job 2 to end
4 - job 2 end2
5 - job 1 ends

Point 3 is not possible. You need to split job 1 into 2 parts, A & B, and do the following:
1 - job 1A starts
2 - job 2 starts
3 - job1A ends
4 - job 2 ends
5 - job 1B starts
5 - job 1B ends

Jobs are independent entities.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

Re: Check status of jobs in REXX

Postby crazydoc » Fri Jun 17, 2016 3:58 pm

Probably my bad English... It looks like this:
1)Start Job1
_1.1)Start step1
____1.1.1)Start REXX
_________1.1.1.1)Create control card, submit, wait
_________1.1.1.2)Return RC
_1.2)Start step2
____1.2.1)Start REXX
_________1.2.1.1)Create control card, submit, wait
_________1.2.1.2)Return RC
_1.2)END JCL.
Encapsulate.
crazydoc
 
Posts: 50
Joined: Fri Jul 24, 2015 12:27 pm
Has thanked: 2 times
Been thanked: 0 time

Re: Check status of jobs in REXX

Postby willy jensen » Sat Jun 18, 2016 12:14 am

Many ways to skin that particular cat.
This sample uses the REXX/SDSF API to list the log file of job VTAM. Your program must of course determine of the job has completed and with what condition code. You may have to read file 3 rather than file 1 for that. I'll leave that up to you.

 address TSO                                                    
 jbn='VTAM'                                                    
 say 'Searching for' jbn                                        
                                                               
 rc=isfcalls('ON')                                              
 isfprefix=jbn                                                  
 isfdest  ='LOCAL'                                              
 Address SDSF "ISFEXEC ST"                                      
 if rc<>0 then call msgrtn rc "ISFEXEC ST"                      
                                                               
 /******************************/                              
 /* Loop for all matching jobs */                              
 /******************************/                              
 do ix=1 to JNAME.0                                            
   say 'in-queue:' JNAME.ix jobid.ix                            
   if JNAME.ix = jbn then do                                    
     say ' '                                                    
     /******************************************/              
     /* Issue the SA action against the row to */              
     /* allocate all data sets in the job. */                  
     /******************************************/              
     Address SDSF "ISFACT ST TOKEN('"TOKEN.ix"') PARM(NP SA)"  
     if rc<>0 then call msgrtn rc "ISFACT ST TOKEN"            
     /************************************************/        
     /* The data set name for each allocated data */            
     /* set is contained in the isfdsname stem. The */          
     /* ddname returned by allocation is contained */          
     /* in the isfddname stem. */                              
     /************************************************/        
     Say "Number of data sets allocated:" value(isfdsname".0")  
     /*****************************************************/    
     /* Read the records from log file                    */    
     /*****************************************************/    
     Say "Listing log"                                          
     "EXECIO * DISKR" isfddname.1 "(STEM line. FINIS"          
     Say "File contains" line.0 "lines"                        
     do kx = 1 to line.0                                        
       Say line.kx                                              
     end                                                        
   end                                                          
   Call Close 0                                                
 end                                                            
                                                               
 /* terminate */                                                
 Call Close 0 ''

Close:                                                  
 rc=isfcalls('OFF')                                      
 parse arg _rc _msg                                      
 if _msg<>'' then say _msg                              
 Exit word(_rc 0,1)                                      
                                                         
msgrtn:    /* SUBROUTINE TO LIST ERROR MESSAGES */      
 arg msgrc msgfunc                                      
 if msgrc=0 then return                                  
 say msgrc 'returned from' msgfunc                      
 /************************************************/      
 /* The isfmsg variable contains a short message */      
 /************************************************/      
 if isfmsg<>"" then Say "isfmsg is:" isfmsg              
 /****************************************************/  
 /* The isfmsg2 stem contains additional descriptive */  
 /* error messages */                                    
 /****************************************************/  
 do msgix=1 to isfmsg2.0                                
   Say "isfmsg2."msgix "is:" isfmsg2.msgix              
 end                                                    
 call close 8                                            
 

These users thanked the author willy jensen for the post:
crazydoc (Mon Jun 20, 2016 11:00 am)
willy jensen
 
Posts: 455
Joined: Thu Mar 10, 2016 5:03 pm
Has thanked: 0 time
Been thanked: 69 times

Next

Return to JCL

 


  • Related topics
    Replies
    Views
    Last post