View previous topic :: View next topic
|
Author |
Message |
ozgurseyrek
New User
Joined: 22 Feb 2008 Posts: 70 Location: Turkey
|
|
|
|
Hi,
In my jcl a have a lot of steps, I want to interrupt the executing if the steps return codes are greater than 4 and not equal to 166.
But coding "IF/THEN/ELSE.." for every step is not practical.
The JCL will execute the next step if RC = 1,2,3,4 and 166. otherwise will terminete the executing. And I want achieve it by the job card.
Is it possible? Thanks. |
|
Back to top |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
What about RC = 0? |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8796 Location: Welsh Wales
|
|
|
|
Unfortunately the COND= checks are ' OR ' checks, so as long as any one condition is met the job will terminate. |
|
Back to top |
|
|
ozgurseyrek
New User
Joined: 22 Feb 2008 Posts: 70 Location: Turkey
|
|
|
|
Yes, sorry. 0 means not error.
The JCL will execute the next step if RC = 0,1,2,3,4 and 166. |
|
Back to top |
|
|
Terry Heinze
JCL Moderator
Joined: 14 Jul 2008 Posts: 1248 Location: Richfield, MN, USA
|
|
|
|
How many is "a lot of steps"? It might be better to bite the bullet now rather than force others to deal with the reverse logic of COND statements. |
|
Back to top |
|
|
ozgurseyrek
New User
Joined: 22 Feb 2008 Posts: 70 Location: Turkey
|
|
|
|
There are 15, 20 setps in a JCL. |
|
Back to top |
|
|
Terry Heinze
JCL Moderator
Joined: 14 Jul 2008 Posts: 1248 Location: Richfield, MN, USA
|
|
|
|
With ISPF's editing capabilities, it would take less than 20 minutes to insert 20 IF/THEN/ENDIF statements in a JCL. Why is this not practical? |
|
Back to top |
|
|
parsesource
New User
Joined: 06 Feb 2006 Posts: 97
|
|
|
|
ozgurseyrek wrote: |
Hi,
In my jcl a have a lot of steps, I want to interrupt the executing if the steps return codes are greater than 4 and not equal to 166.
But coding "IF/THEN/ELSE.." for every step is not practical.
The JCL will execute the next step if RC = 1,2,3,4 and 166. otherwise will terminete the executing. And I want achieve it by the job card.
Is it possible? Thanks. |
try this using a single IF
Code: |
//... JOB ...
// IF (RC LE 4 OR RC EQ 166) THEN
// all your steps
// ENDIF
|
|
|
Back to top |
|
|
gcicchet
Senior Member
Joined: 28 Jul 2006 Posts: 1702 Location: Australia
|
|
|
|
Hi,
has this been tested or is it just a stab in the dark
Code: |
//... JOB ...
// IF (RC LE 4 OR RC EQ 166) THEN
// all your steps
// ENDIF
|
Gerry |
|
Back to top |
|
|
ozgurseyrek
New User
Joined: 22 Feb 2008 Posts: 70 Location: Turkey
|
|
|
|
"IF/ENDIF" doesn't work I think, because if any of my steps in "IF/ENDIF" clause return greater than 4 RC, the JCL will run the next step.
I will type COND parameter for each step.
Code: |
COND=((166,EQ,STEP1),(4,LT)) |
thanks. |
|
Back to top |
|
|
parsesource
New User
Joined: 06 Feb 2006 Posts: 97
|
|
|
|
you donĀ“t believe me? try this
Code: |
// ... Job ...
// IF (RC=0) THEN
//STEP1 EXEC PGM=IDCAMS => creates RC=12
//STEP2 EXEC PGM=IEFBR14
// ENDIF
|
STEP2 will be flushed. RC (= max-RC of all previous steps) will be evaluated at every step.
i was very surprised too, when i first saw this behaviour. the jcl-reference
is not clear about this |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
parsesource wrote: |
the jcl-reference is not clear about this
RC (= max-RC of all previous steps) will be evaluated at every step. |
This is what I could in find in the same manual.
"An IF statement specified before the first EXEC statement in a job is not evaluated before the first step executes. If the IF statement applies to later steps in the job, the statement will be evaluated when the system decides whether to process the later steps."
Hence in your example if you had 4 steps and if the 2nd step had an RC=12, still the remaining steps would still be executed. But if the first step returns an non-zero-RC then all the remaining steps would be bypassed.
ozgurseyrek wrote: |
I will type COND parameter for each step. |
Why not code the same in your JOB statement instead? |
|
Back to top |
|
|
ozgurseyrek
New User
Joined: 22 Feb 2008 Posts: 70 Location: Turkey
|
|
|
|
Answer to parsesource;
Code: |
// ... Job ...
// IF (RC=0) THEN
//STEP1 EXEC PGM=IDCAMS => creates RC=12
//STEP2 EXEC PGM=IEFBR14
// ENDIF |
at that code sample IF STEP1 creates RC=12, STEP2 is executing.
(Check that you are not using COND parameter at JOB card) |
|
Back to top |
|
|
ozgurseyrek
New User
Joined: 22 Feb 2008 Posts: 70 Location: Turkey
|
|
|
|
Answer to arcvns;
You asked that
"Why not code the same in your JOB statement instead?"
Code: |
COND=((166,EQ,STEP1),(4,LT)) |
I can not type that COND paramaters at the JOB CARD. It is in JCL Error.
I can not use Stepname at Job card CONDitions. |
|
Back to top |
|
|
ozgurseyrek
New User
Joined: 22 Feb 2008 Posts: 70 Location: Turkey
|
|
|
|
New answer to arcvns;
IF you suggesting the use COND parameter at job card likte that;
Code: |
COND=((166,NE),(4,LT)) |
It dosnt't work. For 166 RC, the JCL will terminate because "4,LT" condition item will be true. |
|
Back to top |
|
|
Terry Heinze
JCL Moderator
Joined: 14 Jul 2008 Posts: 1248 Location: Richfield, MN, USA
|
|
|
|
Why are you insisting upon using COND instead of the newer and recommended IF/THEN/ELSE/ENDIF construct? Why can't you insert the following 2 statements between each of your 20 steps:
Code: |
// ENDIF
// IF (RC GE 0001 AND RC LE 0004) OR (RC EQ 0166) THEN |
and add an IF before the 1st step and an ENDIF after the last step? Using either a block copy or a copy and paste, this would take very little time to code. This is untested JCL since I don't have mainframe access. |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
ozgurseyrek,
I dint really see your condition codes. May be you'll have to use the posted IF/THEN approach. |
|
Back to top |
|
|
parsesource
New User
Joined: 06 Feb 2006 Posts: 97
|
|
|
|
arcvns wrote: |
parsesource wrote: |
the jcl-reference is not clear about this
RC (= max-RC of all previous steps) will be evaluated at every step. |
This is what I could in find in the same manual.
"An IF statement specified before the first EXEC statement in a job is not evaluated before the first step executes. If the IF statement applies to later steps in the job, the statement will be evaluated when the system decides whether to process the later steps."
Hence in your example if you had 4 steps and if the 2nd step had an RC=12, still the remaining steps would still be executed. But if the first step returns an non-zero-RC then all the remaining steps would be bypassed.
ozgurseyrek wrote: |
I will type COND parameter for each step. |
Why not code the same in your JOB statement instead? |
you are right. the reason for my wrong assumption is a misleading statement in the JCL Reference "Note: At the start of execution, RC is initially set to zero."
Because of this I thought, that before execution of STEP1 the "IF RC=0" statement evaluates to TRUE. So bypassing of STEP2 could only happen because RC is reevaluated within IF,ENDIF |
|
Back to top |
|
|
Terry Heinze
JCL Moderator
Joined: 14 Jul 2008 Posts: 1248 Location: Richfield, MN, USA
|
|
|
|
To get around the JCL rule that the RC is always zero prior to executing the 1st step, 2 options are possible:1. Do not enclose the 1st step with an IF/ENDIF statement or 2. Include 0000 as an acceptable RC for executing step 1. |
|
Back to top |
|
|
Terry Heinze
JCL Moderator
Joined: 14 Jul 2008 Posts: 1248 Location: Richfield, MN, USA
|
|
|
|
P.S. A 3rd option is to exec an IEFBR14 as the 1st step in the job. |
|
Back to top |
|
|
Terry Heinze
JCL Moderator
Joined: 14 Jul 2008 Posts: 1248 Location: Richfield, MN, USA
|
|
|
|
P.P.S. Sorry. Option 3 puts you back at square 1. I'd use either option 1 or 2. |
|
Back to top |
|
|
|