IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Can we get the return code of a job in some variable


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
baldi

New User


Joined: 16 Jun 2005
Posts: 13
Location: Amsterdam

PostPosted: Fri Jun 24, 2005 4:26 pm
Reply with quote

Can we get the return code of a job in some variable, some how!! Using Cobol or REXX?? Actually I am in process of automating Compilation process for mass jobs, and want to store their respective return codes in some file!!
Any suggestion will be welcome.
Back to top
View user's profile Send private message
MGIndaco

Active User


Joined: 10 Mar 2005
Posts: 432
Location: Milan, Italy

PostPosted: Fri Jun 24, 2005 9:17 pm
Reply with quote

Do you need the Return Code of single step or about the end of Job?
Back to top
View user's profile Send private message
baldi

New User


Joined: 16 Jun 2005
Posts: 13
Location: Amsterdam

PostPosted: Sat Jun 25, 2005 10:52 am
Reply with quote

For whole of the job,, the final RC,that is shown to the NOTIFY=whtever terminal. I want to capture it and store it in some variable for all the jobs and then print a report of them in the end.

POSSIBLE??
Back to top
View user's profile Send private message
superk

Global Moderator


Joined: 26 Apr 2004
Posts: 4652
Location: Raleigh, NC, USA

PostPosted: Mon Jun 27, 2005 5:36 pm
Reply with quote

I use this exec to log the return-codes for each step of the job. It runs as the very last step:
Code:

/* REXX GETRC                        */                   
/* GET THE STEP NAME AND RETURN CODE */                   
NUMERIC DIGITS(32) /* ENSURE MAX PRECISION */             
TCB=STORAGE(D2X(540),4) /* PSATOLD IN PSA */             
JSCB =STORAGE(D2X(C2D(TCB)+180),4) /* TCBJSCB IN TCB */   
JCT = STORAGE(D2X(C2D(JSCB)+261),3) /* JSCBJCTA IN JSCB */
THIS_STEP_NO = X2D(C2X(STORAGE(D2X(C2D(JSCB)+228),1)))   
/* THIS STEP NO. */                                       
FSCT = STORAGE(D2X(C2D(JCT)+48),3) /* JCTSDKAD IN JCT */ 
/* IS FIRST SCT */                                       
TEMP_SCT = FSCT                                           
DO I = 1 TO (THIS_STEP_NO - 1)                                       
  STEP = STORAGE(D2X(C2D(TEMP_SCT)+68),8)                             
  RCSTEP = X2D(C2X(STORAGE(D2X(C2D(TEMP_SCT)+24),2)))                 
  /* SCTSEXEC IN SCT */                                               
  BYPASS = STORAGE(D2X(C2D(TEMP_SCT)+188),1)                         
  IF X2D(C2X(BYPASS)) = 80 THEN /* CHECK IF STEP WAS NOT EXECUTED */ 
    DO                                                               
      RCSTEP = 'FLUSHED '                                             
    END                                                               
  SAY 'STEP ==>' STEP ' RC ==>' RCSTEP                               
  TEMP_SCT = STORAGE(D2X(C2D(TEMP_SCT)+36),3)                         
END                                                                   
EXIT                                                                 

Please note that this code is from public-domain freeware, so I take no credit for the content.
Back to top
View user's profile Send private message
kcprem

New User


Joined: 30 Jun 2005
Posts: 18

PostPosted: Wed Jul 06, 2005 5:27 am
Reply with quote

Hi SuperK,

Can you please tell me how to add this code with the existing job?

Thanks,
Prem
Back to top
View user's profile Send private message
superk

Global Moderator


Joined: 26 Apr 2004
Posts: 4652
Location: Raleigh, NC, USA

PostPosted: Wed Jul 06, 2005 3:46 pm
Reply with quote

Code:

//LASTSTEP EXEC PGM=IRXJCL,PARM='GETRC'
//SYSEXEC  DD   DISP=SHR,DSN=YOUR.REXX.PARMLIB
//SYSTSPRT DD   SYSOUT=*
//SYSTSIN  DD   DUMMY
Back to top
View user's profile Send private message
kcprem

New User


Joined: 30 Jun 2005
Posts: 18

PostPosted: Wed Jul 06, 2005 7:36 pm
Reply with quote

Hi SuperK,

After adding laststep in jcl, I am getting the following error. Can you please check and let me know the problem.

JOB09894 +IRX0408E Exec member name must not be specified when exec load DD refers to a sequential data set.
JOB09894 +IRX0110I The REXX exec cannot be interpreted.
JOB09894 +IRX0112I The REXX exec cannot be loaded.
JOB09894 -RCKCHKSP LASTSTEP 20 8 .00 .00 .0 99

Thanks,
Prem
Back to top
View user's profile Send private message
MGIndaco

Active User


Joined: 10 Mar 2005
Posts: 432
Location: Milan, Italy

PostPosted: Wed Jul 06, 2005 8:42 pm
Reply with quote

This error happen when you define a sequential dataset in SYSEXEC. You must put the Super(k) code in a member of partitioned with lrecl=80 and in jcl specify only the name of partitioned. The name of the member is indicated in PARM='membername'.
I hope in this help
Back to top
View user's profile Send private message
kcprem

New User


Joined: 30 Jun 2005
Posts: 18

PostPosted: Thu Jul 07, 2005 12:25 am
Reply with quote

Hi MGIndaco,

Thanks for your reply/help. Now it's working fine.

Regards,
Prem
Back to top
View user's profile Send private message
subbaraorv

New User


Joined: 09 May 2005
Posts: 2

PostPosted: Thu Jul 14, 2005 1:27 pm
Reply with quote

Really a good one .............
Back to top
View user's profile Send private message
Unique

New User


Joined: 10 Jul 2007
Posts: 24
Location: Blore

PostPosted: Thu Jul 19, 2007 10:18 am
Reply with quote

The above exec give RC for each step.Anyway to directly get the MAXCC of the job thru the same exec . I apologize if this question sounds silly as i am very new to REXX.
Back to top
View user's profile Send private message
feellikeneo

New User


Joined: 19 Mar 2007
Posts: 73
Location: Chennai

PostPosted: Mon Sep 03, 2007 5:35 pm
Reply with quote

Code:
/* REXX GETRC                        */                                 
/* GET THE STEP NAME AND RETURN CODE */                                 
Numeric Digits(32) /* ENSURE MAX PRECISION */                           
TCB=Storage(D2X(540),4) /* PSATOLD IN PSA */                           
JSCB = Storage(D2X(C2D(TCB)+180),4) /* TCBJSCB IN TCB */               
JCT  = Storage(D2X(C2D(JSCB)+261),3) /* JSCBJCTA IN JSCB */             
This_Step_No = X2D(C2X(Storage(D2X(C2D(JSCB)+228),1)))                 
/* THIS STEP NO. */                                                     
FSCT = Storage(D2X(C2D(JCT)+48),3) /* JCTSDKAD IN JCT */               
/* IS FIRST SCT */                                                     
TEMP_SCT = FSCT                                                         
ArrIdx = 1                                                             
Do I = 1 TO (THIS_STEP_NO - 1)                                         
  STEP = Storage(D2X(C2D(TEMP_SCT)+68),8)                               
  RCSTEP = X2D(C2X(Storage(D2X(C2D(TEMP_SCT)+24),2)))                   
  /* SCTSEXEC IN SCT */                                                 
  ByPass = Storage(D2X(C2D(TEMP_SCT)+188),1)                           
  If X2D(C2X(BYPASS)) = 80 then /* CHECK IF STEP WAS NOT EXECUTED */   
    Do                                                             
     RCSTEP = 'FLUSHED '                                           
    End                                                             
  Say 'STEP ==>' STEP ' RC ==>' RCSTEP                             
  Array1.Idx = RCSTEP                                           
  Idx = Idx + 1                                               
  TEMP_SCT = Storage(D2X(C2D(TEMP_SCT)+36),3)                       
End                                                                 
                                                                   
IdxMax = (Idx - 1)                                           
MaxCode = Array1.1                                               
Do Idx = 2 to ArrIdxMax                                         
   If Array1.Idx > MaxCode Then                               
      do                                                           
        MaxCode = Array1.Idx                                 
      End                                                           
End                                                                 
Say 'Max Return Code is ' MaxCode                               
Exit                                                               
Return


try this one
Back to top
View user's profile Send private message
hermit_reloaded

New User


Joined: 23 Apr 2007
Posts: 26
Location: India

PostPosted: Thu Jan 24, 2008 9:12 am
Reply with quote

Hi,

Can anybody tell me what is the logic behind above program......
or can direct me to website where i can find more information
(really new to REXX)
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu Jan 24, 2008 9:24 am
Reply with quote

Hello,

The "above program" is pretty well commented.

One thing that would make it more difficult for someone who is learning is that the code references some of the system control blocks (an entirely different set of knowledge).

I'd suggest you run the code with TRACE and watch what happens.
Back to top
View user's profile Send private message
kabyab

New User


Joined: 31 Aug 2005
Posts: 34
Location: Pune, India

PostPosted: Tue Aug 26, 2008 4:34 pm
Reply with quote

Has anyone tried with the code provided by feellikeneo ?
I got a Max-RC 3657 while executing with that.

This is what I got in SYSTSPRT LASTSTEP :

Code:

******************** TOP OF DATA ***********************
STEP ==> SEARCH    RC ==> 1                                       
    24 +++  Idx = Idx + 1                                         
IRX0041I Error running GETRC, line 24: Bad arithmetic conversion 
******************* BOTTOM OF DATA ********************


The JCL I am running is:

Code:

//SRCHFORE JOB (SRCH,FO),'SERC',REGION=8M,CLASS=C,
//     MSGCLASS=A,NOTIFY=&SYSUID                   
//SEARCH  EXEC PGM=ISRSUPC,                       
//            PARM=(SRCHCMP,                       
//            'ANYC')                             
//NEWDD  DD DSN=KB8796.BASI.SRC,                 
//          DISP=SHR                               
//OUTDD  DD DSN=KB8796.SRCH.REXX1,             
//          DISP=(NEW,CATLG),UNIT=SYSDA,           
//          SPACE=(0,(50,100),RLSE),               
//          DCB=(BLKSIZE=0)                       
//SYSIN  DD *                                     
SRCHFOR  'B2CCT'                                   
/*                                                 
//LASTSTEP EXEC PGM=IRXJCL,PARM='GETRC'           
//SYSEXEC  DD   DISP=SHR,DSN=KB8796.REXX.SOURCE
//SYSTSPRT DD   SYSOUT=*                           
//SYSTSIN  DD   DUMMY                             


The code what superk has mentioned is working fine.
But I was looking forward to finding out the MAXCC (RC for the Job) and not RC for each step in the JCL.

Thanks
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Tue Aug 26, 2008 4:48 pm
Reply with quote

Because the code posted is untested by the poster.
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Tue Aug 26, 2008 5:21 pm
Reply with quote

How can the last step in a job return the max cc for the job since the job hasn't finished yet?
Back to top
View user's profile Send private message
kabyab

New User


Joined: 31 Aug 2005
Posts: 34
Location: Pune, India

PostPosted: Tue Aug 26, 2008 5:29 pm
Reply with quote

After the job is finished is it possible for us to capture the MAXCC through REXX? If it is possible, then how can we do that? any code snippet or any guidance is most welcome.

Thanks
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Tue Aug 26, 2008 5:56 pm
Reply with quote

Craq Giegerich wrote:
How can the last step in a job return the max cc for the job since the job hasn't finished yet?

Because it is the last step in the job it can get the previous RC's

The posted code will give you exactly what you need, but you will need to work on it to fix the errors
Back to top
View user's profile Send private message
Pedro

Global Moderator


Joined: 01 Sep 2006
Posts: 2546
Location: Silicon Valley

PostPosted: Tue Aug 26, 2008 9:45 pm
Reply with quote

SuperK's example examines all return codes. You should be able to modify to examine all and also save the highest return code.

That is, you should be able to... feellikeneo tried, but was not able to modify successfully. Idx is not initialized. Looks like feellikeneo got confused between usage of ArrIdx and Idx. Also confused between ArrIdxMax and IdxMax
Back to top
View user's profile Send private message
MikeHunter

New User


Joined: 02 Aug 2006
Posts: 2

PostPosted: Tue Feb 21, 2012 3:48 pm
Reply with quote

What about:

Code:

/* REXX GETMAXRC                                  */                   
/* GET THE STEP NAME AND RETURN CODE */                   
NUMERIC DIGITS(32) /* ENSURE MAX PRECISION */             
TCB=STORAGE(D2X(540),4) /* PSATOLD IN PSA */             
JSCB =STORAGE(D2X(C2D(TCB)+180),4) /* TCBJSCB IN TCB */   
JCT = STORAGE(D2X(C2D(JSCB)+261),3) /* JSCBJCTA IN JSCB */
THIS_STEP_NO = X2D(C2X(STORAGE(D2X(C2D(JSCB)+228),1)))   
/* THIS STEP NO. */                                       
FSCT = STORAGE(D2X(C2D(JCT)+48),3) /* JCTSDKAD IN JCT */
/* IS FIRST SCT */                                       
TEMP_SCT = FSCT                                         
MAXRC = 0 
DO I = 1 TO (THIS_STEP_NO - 1)                                       
  STEP = STORAGE(D2X(C2D(TEMP_SCT)+68),8)                             
  RCSTEP = X2D(C2X(STORAGE(D2X(C2D(TEMP_SCT)+24),2)))                 
  /* SCTSEXEC IN SCT */                                               
  BYPASS = STORAGE(D2X(C2D(TEMP_SCT)+188),1)                         
  IF X2D(C2X(BYPASS)) = 80 THEN /* CHECK IF STEP WAS NOT EXECUTED */
    DO                                                               
      RCSTEP = 'FLUSHED '                                             
    END                                                               
  SAY 'STEP ==>' STEP ' RC ==>' RCSTEP                               
  IF RCSTEP > MAXRC THEN MAXRC = RCSTEP
  TEMP_SCT = STORAGE(D2X(C2D(TEMP_SCT)+36),3)                         
END   
SAY 'MAXRC ==>' MAXRC                                                               
EXIT
RETURN
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Tue Feb 21, 2012 3:57 pm
Reply with quote

nice try Mike icon_wink.gif

The topic has been resurrected after
Code:
...          3 year(s) - (months difference / 12 )
...          4 year(s) - (difference )
...         42 months
...       1273 days
...      30570 hours
...    1834203 minutes
...  110052180 seconds


but... the guinnes is still this one
www.ibmmainframes.com/viewtopic.php?t=146&highlight=guinness
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Tue Feb 21, 2012 6:51 pm
Reply with quote

I wonder, Mike had been here since 2006 and original discussion started mid 2005 and the latest post is in 2012 - something does not match up here...



PS.: Don't read Sherlock Holmes while going to sleep... icon_biggrin.gif
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts run rexx code with jcl CLIST & REXX 15
No new posts Compile rexx code with jcl CLIST & REXX 6
No new posts Return codes-Normal & Abnormal te... JCL & VSAM 7
No new posts REXX code to expand copybook in a cob... CLIST & REXX 2
Search our Forums:

Back to Top