Page 1 of 2

How to set return code of whole job to 0 ?

PostPosted: Fri Jan 02, 2015 11:35 am
by swatmf14
I have some steps in my job which are getting abended. Depends on the return code of previous steps i am executing next steps. But at the end of execution of all steps i want to set return code of whole job to 0 even if steps are abended. Can anyone please help me on this ? i tried using IDCAMS utility but its not working.

Re: How to set return code of whole job to 0 ?

PostPosted: Fri Jan 02, 2015 2:36 pm
by Aki88
Hello swatmf14,

Curious question, why would you want to set the Max-RC of a job to 0?

I am only guessing here- if it is because you don't want the job to fail in the job scheduler, then usually you can set the conditions in the scheduler itself to ignore certain RCs.

Alternatively, you might want to check here.

Hth!

Re: How to set return code of whole job to 0 ?

PostPosted: Fri Jan 02, 2015 3:05 pm
by swatmf14
I do not want it as the job should not abend in scheduler. As i want it for standardization purpose.
And in addition that steps are inside proc and i am accessing that steps through my job.
Is there any way to get this done by using JOBRC ?

Re: How to set return code of whole job to 0 ?

PostPosted: Fri Jan 02, 2015 3:18 pm
by Aki88
Hello,

It'd be better if you can explain what you want to do in a li'l more detail please.

swatmf14 wrote:As i want it for standardization purpose.
And in addition that steps are inside proc and i am accessing that steps through my job.


This is interesting, how would an RC impact the execution of a PROC in a JCL? RC is returned after the step has executed.
Incase you have multiple PROCs in a JCL and you want the subsequent PROCs to be executed even if a step in the previous PROC has given an unwanted RC, then it can be done by using return code handling using IF-THEN-ELSE constructs (I'm not a very big fan of COND parameter).

swatmf14 wrote:Is there any way to get this done by using JOBRC ?


There are various limiting factors here, starting with - which z/OS version you're on; if you have 1.13 or higher, then have a look at the link shared earlier, Mr.Spock and Enrico have posted links for the manuals, that should get you started; write a small JCL to test the same.
Then if you're stuck somewhere, please share what you've tried and we can guide you.

Re: How to set return code of whole job to 0 ?

PostPosted: Fri Jan 02, 2015 7:44 pm
by Terry Heinze
JCL cannot set the RC for the entire job. It can only set it for the current step within a job. You cannot retroactivly modify the RC of a previous step.

Re: How to set return code of whole job to 0 ?

PostPosted: Sat Jan 03, 2015 12:35 am
by Aki88
Hello Terry,

True that, but IBM has introduced JOBRC parameter in z/OS 1.13 to do just that.
From the 'JCL Reference':



“JOBRC Parameter” on page 404 is a new parameter on the JOB statement to
control how the job return code (presented by JES2 or JES3) is determined.

.....
.....

JOBRC Parameter
Parameter Type
Keyword, optional
Purpose
Use the JOBRC parameter to control how the job completion code (presented by
JES2 or JES3) is set. By default (when JOBRC is not specified), the job completion
code is set to the highest return code of any step, or if the job's execution fails
because of an ABEND, the job completion code is set to the last ABEND code;
however, this parameter can be used to request that the job completion code be set
to the return code of the last exe
Syntax
JOBRC= {MAXRC}
{LASTRC}
{(STEP,stepname[.procstepname]}


Subparameter Definition
MAXRC
The job completion code is set to the highest return code of any step in the job,
or if the completion of the job fails because of an ABEND, the job completion
code is set to the last ABEND code; This is the default parameter.
LASTRC
The job completion code is set to the return code or ABEND code of the last
step that is executed in the job.
(STEP,stepname[.procstepname])
The job completion code is set to the return code or ABEND code of the step
that is indicated by the stepname.[.procstepname] parameter. If this step does
not exist, a JCL error is generated. If this step does not execute, the processing
is the same as if MAXRC is specified. .
Defaults
If not specified, MAXRC is used as the default.

Examples of the JOBRC Parameter
Example 1
JOBRC=LASTRC
This specification indicates to use the return code of the last executed step as the
completion code for the job.

Example 2
JOBRC=(STEP,C.HLASM)
Use the return code for the C step in the HLASM procstepname as the completion
code for the job.


So if a simple IEFBR14 is added in the JCL to set a step return code '0', and JOBRC refers to this particular step, then the end RC can be set to a '0'; though imho, I'd still want to avoid doing this.

Re: How to set return code of whole job to 0 ?

PostPosted: Sat Jan 03, 2015 3:32 am
by Terry Heinze
I stand corrected then. I'm having trouble finding the most recent manual for rel 1.13. Do you have a manual ID for it?

Re: How to set return code of whole job to 0 ?

PostPosted: Sat Jan 03, 2015 12:32 pm
by Aki88
Hello Terry,

The manual I'm using is: SA22-7597-15
For z/OS 2.1: SA23-1385-00

z/OS 2.1 Link

Cheers.

Re: How to set return code of whole job to 0 ?

PostPosted: Sat Jan 03, 2015 8:37 pm
by Terry Heinze
Thanks for the link. We're on z/OS 1.13 so it's not yet available to me. This is the 2.1 version.

Re: How to set return code of whole job to 0 ?

PostPosted: Sat Jan 03, 2015 8:56 pm
by BillyBoyo
Here's a link: http://www-03.ibm.com/systems/z/os/zos/library/bkserv/

Looking in the 1.13 JCL Reference, JOBRC is there, which change-bars to show that it is new.