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

COND parameter at job Card


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

New User


Joined: 22 Feb 2008
Posts: 70
Location: Turkey

PostPosted: Thu Feb 12, 2009 6:41 pm
Reply with quote

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
View user's profile Send private message
Craq Giegerich

Senior Member


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

PostPosted: Thu Feb 12, 2009 6:58 pm
Reply with quote

What about RC = 0?
Back to top
View user's profile Send private message
expat

Global Moderator


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

PostPosted: Thu Feb 12, 2009 6:59 pm
Reply with quote

Unfortunately the COND= checks are ' OR ' checks, so as long as any one condition is met the job will terminate.
Back to top
View user's profile Send private message
ozgurseyrek

New User


Joined: 22 Feb 2008
Posts: 70
Location: Turkey

PostPosted: Thu Feb 12, 2009 7:00 pm
Reply with quote

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
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1248
Location: Richfield, MN, USA

PostPosted: Fri Feb 13, 2009 12:09 am
Reply with quote

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
View user's profile Send private message
ozgurseyrek

New User


Joined: 22 Feb 2008
Posts: 70
Location: Turkey

PostPosted: Fri Feb 13, 2009 12:24 pm
Reply with quote

There are 15, 20 setps in a JCL.
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1248
Location: Richfield, MN, USA

PostPosted: Sat Feb 14, 2009 12:23 pm
Reply with quote

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
View user's profile Send private message
parsesource

New User


Joined: 06 Feb 2006
Posts: 97

PostPosted: Sun Feb 15, 2009 1:18 am
Reply with quote

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
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Sun Feb 15, 2009 12:24 pm
Reply with quote

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
View user's profile Send private message
ozgurseyrek

New User


Joined: 22 Feb 2008
Posts: 70
Location: Turkey

PostPosted: Sun Feb 15, 2009 1:40 pm
Reply with quote

"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
View user's profile Send private message
parsesource

New User


Joined: 06 Feb 2006
Posts: 97

PostPosted: Sun Feb 15, 2009 2:42 pm
Reply with quote

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
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Sun Feb 15, 2009 3:33 pm
Reply with quote

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
View user's profile Send private message
ozgurseyrek

New User


Joined: 22 Feb 2008
Posts: 70
Location: Turkey

PostPosted: Sun Feb 15, 2009 4:11 pm
Reply with quote

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
View user's profile Send private message
ozgurseyrek

New User


Joined: 22 Feb 2008
Posts: 70
Location: Turkey

PostPosted: Sun Feb 15, 2009 4:16 pm
Reply with quote

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
View user's profile Send private message
ozgurseyrek

New User


Joined: 22 Feb 2008
Posts: 70
Location: Turkey

PostPosted: Sun Feb 15, 2009 4:20 pm
Reply with quote

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
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1248
Location: Richfield, MN, USA

PostPosted: Sun Feb 15, 2009 9:56 pm
Reply with quote

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
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Sun Feb 15, 2009 10:01 pm
Reply with quote

ozgurseyrek,

I dint really see your condition codes. May be you'll have to use the posted IF/THEN approach.
Back to top
View user's profile Send private message
parsesource

New User


Joined: 06 Feb 2006
Posts: 97

PostPosted: Tue Feb 17, 2009 2:50 am
Reply with quote

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
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1248
Location: Richfield, MN, USA

PostPosted: Tue Feb 17, 2009 3:13 am
Reply with quote

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
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1248
Location: Richfield, MN, USA

PostPosted: Tue Feb 17, 2009 3:14 am
Reply with quote

P.S. A 3rd option is to exec an IEFBR14 as the 1st step in the job.
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1248
Location: Richfield, MN, USA

PostPosted: Tue Feb 17, 2009 3:18 am
Reply with quote

P.P.S. Sorry. Option 3 puts you back at square 1. I'd use either option 1 or 2.
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 SORT CARD meaning please DFSORT/ICETOOL 3
No new posts Add condition to a FINDREP SORT card DFSORT/ICETOOL 4
No new posts INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts JCL sort card - get first day and las... JCL & VSAM 9
No new posts Using the Jobname parameter in a Qual... ABENDS & Debugging 1
Search our Forums:

Back to Top