Capture the RC of previous step



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

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:
// EXEC ...,COND=(0,NE,stepname)


WAY2:
// IF (stepname.RC EQ 0)
// . . . . . .
// ENDIF
nbcobol
 
Posts: 4
Joined: Mon Jan 06, 2025 7:03 pm
Has thanked: 0 time
Been thanked: 0 time

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:
//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=
willy jensen
 
Posts: 470
Joined: Thu Mar 10, 2016 5:03 pm
Has thanked: 0 time
Been thanked: 70 times

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

//A   EXEC PGM=ROICUCPY
//*                    
// IF A.RC LE 5 THEN  
//B   EXEC PGM=ROICUCPY
// ENDIF
nbcobol
 
Posts: 4
Joined: Mon Jan 06, 2025 7:03 pm
Has thanked: 0 time
Been thanked: 0 time

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?
willy jensen
 
Posts: 470
Joined: Thu Mar 10, 2016 5:03 pm
Has thanked: 0 time
Been thanked: 70 times

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:
//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:
      58 IEF645I INVALID REFERBACK IN THE RC       FIELD
DTM1455I 2025.007 08:19:13 Job JOBNAME failed, JCL Error
nbcobol
 
Posts: 4
Joined: Mon Jan 06, 2025 7:03 pm
Has thanked: 0 time
Been thanked: 0 time

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:
//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:
      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.
User avatar
sergeyken
 
Posts: 441
Joined: Wed Jul 24, 2019 10:12 pm
Has thanked: 7 times
Been thanked: 40 times

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.
willy jensen
 
Posts: 470
Joined: Thu Mar 10, 2016 5:03 pm
Has thanked: 0 time
Been thanked: 70 times

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!

//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.
User avatar
sergeyken
 
Posts: 441
Joined: Wed Jul 24, 2019 10:12 pm
Has thanked: 7 times
Been thanked: 40 times

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 !
nbcobol
 
Posts: 4
Joined: Mon Jan 06, 2025 7:03 pm
Has thanked: 0 time
Been thanked: 0 time

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.
User avatar
sergeyken
 
Posts: 441
Joined: Wed Jul 24, 2019 10:12 pm
Has thanked: 7 times
Been thanked: 40 times


Return to JCL

 


  • Related topics
    Replies
    Views
    Last post