Capture the RC of previous step

JES, JES2, JCL utilities, IDCAMS, Compile & Run JCLs, PROCs etc...
nbcobol
Posts: 4
Joined: Mon Jan 06, 2025 7:03 pm
Skillset: JCL,COBOL,TSO/ISPF
Referer: GOOGLE

Capture the RC of previous step

Postby nbcobol » Tue Jan 07, 2025 1:00 pm

Hi,

I know that when we use COND parameter as COND=(0,NE) in a step, the condition will be checked against return code of all the previous steps executed.

But my requirement is to check the return code of only the previous step and run the current step if that has a MAXRC NE 0.

I am not able to use STEPNAME.RC, it throws INVALID REFERBACK ERROR.

Can any body help me out on this.

FYI, I have tried the below syntaxes:

WAY 1:

Code: Select all

// EXEC ...,COND=(0,NE,stepname)


WAY2:

Code: Select all

// IF (stepname.RC EQ 0)
// . . . . . .
// ENDIF

willy jensen
Posts: 474
Joined: Thu Mar 10, 2016 5:03 pm
Skillset: assembler rexx zOS ispf racf smf
Referer: saw it in the experts foprum thought I could help here

Re: Capture the RC of previous step

Postby willy jensen » Tue Jan 07, 2025 2:19 pm

You are missing the THEN verb in the 2nd sample, see:

Code: Select all

//A   EXEC PGM=IEFBR14
//*                    
// IF A.RC LE 5 THEN  
//B   EXEC PGM=IEFBR14
// ENDIF              

I will definitely recommend the IF statement instead of the COND=

nbcobol
Posts: 4
Joined: Mon Jan 06, 2025 7:03 pm
Skillset: JCL,COBOL,TSO/ISPF
Referer: GOOGLE

Re: Capture the RC of previous step

Postby nbcobol » Tue Jan 07, 2025 2:39 pm

Hi Willy,

i have tried this syntax as well. The step A exec has a pgm ROICUCPY, which is trying to read a text file from a server location. If this step A runs successfully, it should not run step B(which is the backup server to fetch the file). I'm getting invalid referback for A.RC

Code: Select all

//A   EXEC PGM=ROICUCPY
//*                    
// IF A.RC LE 5 THEN  
//B   EXEC PGM=ROICUCPY
// ENDIF

willy jensen
Posts: 474
Joined: Thu Mar 10, 2016 5:03 pm
Skillset: assembler rexx zOS ispf racf smf
Referer: saw it in the experts foprum thought I could help here

Re: Capture the RC of previous step

Postby willy jensen » Tue Jan 07, 2025 3:05 pm

Is that the entire job? May we see the output?

nbcobol
Posts: 4
Joined: Mon Jan 06, 2025 7:03 pm
Skillset: JCL,COBOL,TSO/ISPF
Referer: GOOGLE

Re: Capture the RC of previous step

Postby nbcobol » Tue Jan 07, 2025 7:00 pm

No the job has other steps.

This is the one I'm getting issues at:

Code: Select all

//A        EXEC ROICUCPY                                    
//UCMDOPT  DD  DSN=[FILE],DISP=SHR  
//UNVOUT   DD  DSN=[FILE],DISP=OLD
//SCRIPT   DD  *                                            
 @echo off                                                  
 UCOPY [filepath]    
/*                                                          
//SYSIN    DD  *                                            
[host details]                                    
//*                                                        
//COND1    IF A.RC NE 0 THEN    
//B        EXEC ROICUCPY  
//UCMDOPT  DD  DSN=[FILE],DISP=SHR  
//UNVOUT   DD  DSN=[FILE],DISP=OLD
//SCRIPT   DD  *                                            
 @echo off                                                  
 UCOPY [filepath]  
//        ENDIF



The error:

Code: Select all

      58 IEF645I INVALID REFERBACK IN THE RC       FIELD
DTM1455I 2025.007 08:19:13 Job JOBNAME failed, JCL Error

User avatar
sergeyken
Posts: 458
Joined: Wed Jul 24, 2019 10:12 pm
Skillset: Assembler, JCL, Utilities, PL/I, C/C++, DB2, SQL, REXX, COBOL, etc. etc. etc.
Referer: Internet search

Re: Capture the RC of previous step

Postby sergeyken » Tue Jan 07, 2025 7:12 pm

nbcobol wrote:No the job has other steps.

This is the one I'm getting issues at:

Code: Select all

//A        EXEC ROICUCPY                                    
//UCMDOPT  DD  DSN=[FILE],DISP=SHR  
//UNVOUT   DD  DSN=[FILE],DISP=OLD
//SCRIPT   DD  *                                            
 @echo off                                                  
 UCOPY [filepath]    
/*                                                          
//SYSIN    DD  *                                            
[host details]                                    
//*                                                        
//COND1    IF A.RC NE 0 THEN    
//B        EXEC ROICUCPY  
//UCMDOPT  DD  DSN=[FILE],DISP=SHR  
//UNVOUT   DD  DSN=[FILE],DISP=OLD
//SCRIPT   DD  *                                            
 @echo off                                                  
 UCOPY [filepath]  
//        ENDIF



The error:

Code: Select all

      58 IEF645I INVALID REFERBACK IN THE RC       FIELD
DTM1455I 2025.007 08:19:13 Job JOBNAME failed, JCL Error

When your EXEC statement executed JCL procedure (via // EXEC [PROC=]procname) rather than a load module (via // EXEC PGM=program), then you must have so called "combined stepname": jobstep.procstep

In your case jobstep is A, while your procstep you must find inside your procedure ROICUCPY.

RTFM, RTFM, and RTFM!

P.S.
It is a very bad starting habit, to call any programming entities with the names like A, B, C, X, Y, Z. As well as: var1, n5, t3, etc.
Javas and Pythons come and go, but JCL and SORT stay forever.

willy jensen
Posts: 474
Joined: Thu Mar 10, 2016 5:03 pm
Skillset: assembler rexx zOS ispf racf smf
Referer: saw it in the experts foprum thought I could help here

Re: Capture the RC of previous step

Postby willy jensen » Tue Jan 07, 2025 7:45 pm

Well, apparently '//A EXEC PGM=ROICUCPY' was not what you had problems with, as sergeyken already has pointed out. Always good to see the entire job.

User avatar
sergeyken
Posts: 458
Joined: Wed Jul 24, 2019 10:12 pm
Skillset: Assembler, JCL, Utilities, PL/I, C/C++, DB2, SQL, REXX, COBOL, etc. etc. etc.
Referer: Internet search

Re: Capture the RC of previous step

Postby sergeyken » Tue Jan 07, 2025 8:19 pm

Learn good manners from the very beginning.

Your used names in the JCL were terrible...
Not acceptable even for two-step job, to say nothing about future 200-step jobs!

Code: Select all

//READINIT EXEC ROICUCPY                                    
// . . . . . . . . . .                                                    
// IF (READINIT.procstep.RC NE 0) THEN    
//FETCH EXEC ROICUCPY  
// . . . . . . . . . .                                                    
// ENDIF
Javas and Pythons come and go, but JCL and SORT stay forever.

nbcobol
Posts: 4
Joined: Mon Jan 06, 2025 7:03 pm
Skillset: JCL,COBOL,TSO/ISPF
Referer: GOOGLE

Re: Capture the RC of previous step

Postby nbcobol » Wed Jan 08, 2025 12:57 am

I looked for the procedure and found the procstep to use in my jcl, worked perfectly.
Thanks Willy & Ken !

User avatar
sergeyken
Posts: 458
Joined: Wed Jul 24, 2019 10:12 pm
Skillset: Assembler, JCL, Utilities, PL/I, C/C++, DB2, SQL, REXX, COBOL, etc. etc. etc.
Referer: Internet search

Re: Capture the RC of previous step

Postby sergeyken » Thu Jan 09, 2025 11:59 pm

nbcobol wrote:I looked for the procedure and found the procstep to use in my jcl, worked perfectly.
Thanks Willy & Ken !

Just RTFM. No miracles!
Javas and Pythons come and go, but JCL and SORT stay forever.


  • Similar Topics
    Replies
    Views
    Last post