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

JCL if else condition


IBM Mainframe Forums -> Mainframe Interview Questions
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
RedDevil711

New User


Joined: 04 Jun 2010
Posts: 25
Location: Pune

PostPosted: Thu Mar 03, 2011 12:20 pm
Reply with quote

Can we use and IF ELSE condition on a JCL step based on the value of a SYMBOLIC parameter ?
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Thu Mar 03, 2011 1:15 pm
Reply with quote

why not click on the IBM manuals link at the top of the page

look at
zOS JCL reference
and
zOS JCL user guide

and find out Yourself!
Back to top
View user's profile Send private message
Phrzby Phil

Senior Member


Joined: 31 Oct 2006
Posts: 1042
Location: Richmond, Virginia

PostPosted: Thu Mar 03, 2011 6:15 pm
Reply with quote

Or could you not try this in about one minute?

I mean really folks, how lazy can you get?

If you aspire to be your shop's guru, then learn how to just do something already.
Back to top
View user's profile Send private message
superk

Global Moderator


Joined: 26 Apr 2004
Posts: 4652
Location: Raleigh, NC, USA

PostPosted: Thu Mar 03, 2011 8:06 pm
Reply with quote

Sure. If I define a valid symbolic:

Code:
// SET CND='STEP0001.RC GT 0'

and then use that in my job ...
Code:
//*
//STEP0001 EXEC PGM=...
//*
// IF &CND THEN
//STEP0002 EXEC PGM=...
// ENDIF
//*


it will work as you'd expect.

Although, I'm not sure I see a practical application of this concept.
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1788
Location: Bloomington, IL

PostPosted: Thu Mar 03, 2011 8:22 pm
Reply with quote

Phrzby Phil wrote:
Or could you not try this in about one minute?

I mean really folks, how lazy can you get?

If you aspire to be your shop's guru, then learn how to just do something already.

Without attempting to defend the TS, I'll note that I've been accused of practicing the black arts in writing my own JCL. The attitude -- defended by some of the senior members of this board -- that this late in history everything has been done, and that the preferred way to create X is to "clone" Y and make the absolute minimum of changes, is probably responsible for this.
Back to top
View user's profile Send private message
RedDevil711

New User


Joined: 04 Jun 2010
Posts: 25
Location: Pune

PostPosted: Fri Mar 04, 2011 11:14 am
Reply with quote

@ Phil && @ enrico icon_smile.gif it is not that i did not try myself / scan the manuals on the forum before posting..all the manual says is that we can use RC/ABEND CC/USER ABEND CODES for if and else condition. icon_rolleyes.gif
i actually have a symbolic parameter...user_code whose value can be 'V'/'F'. if it is 'F' i need to copy user info onto a file in a FB format..with DSN parameters and if it is 'V' i need to go and copy user data to a VSAM..
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Fri Mar 04, 2011 12:35 pm
Reply with quote

Quote:
all the manual says is that we can use RC/ABEND CC/USER ABEND CODES for if and else condition.


if that is what the manual says, then You cannot use anything else!
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Fri Mar 04, 2011 2:27 pm
Reply with quote

RedDevil711 wrote:
@ Phil && @ enrico icon_smile.gif it is not that i did not try myself / scan the manuals on the forum before posting..all the manual says is that we can use RC/ABEND CC/USER ABEND CODES for if and else condition. icon_rolleyes.gif
i actually have a symbolic parameter...user_code whose value can be 'V'/'F'. if it is 'F' i need to copy user info onto a file in a FB format..with DSN parameters and if it is 'V' i need to go and copy user data to a VSAM..
Then you should look at what Kevin has suggested.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8697
Location: Dubuque, Iowa, USA

PostPosted: Fri Mar 04, 2011 4:10 pm
Reply with quote

IIRC, the manual actually states using anything other than the allowed constructs in an IF statement results in unpredictable results.

People new to JCL want to use the IF statement like they would a programming language IF statement. The JCL IF statement is actually a very, very, very restricted statement and is good only for certain applications.
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1788
Location: Bloomington, IL

PostPosted: Fri Mar 04, 2011 4:19 pm
Reply with quote

RedDevil711 wrote:
i actually have a symbolic parameter...user_code whose value can be 'V'/'F'. if it is 'F' i need to copy user info onto a file in a FB format..with DSN parameters and if it is 'V' i need to go and copy user data to a VSAM..

So, you write a little piece of code that reads that parameter (a symbolic parameter can be used in the "PARM=" sub-parameter) and either actually writes the data set, or at worse returns an actual return code to control conditional execution of subsequent steps.

Dr. Sorichetti is entirely correct in saying that if a manual says "You may do X or Y', then X or Y are your only choices. You may luck into finding some undocumented logic (there is some in the DSP that interprets the IF construct), but IBM may arbitrary change it at any time in the future, and if it stops working IBM will tell you "Too bad, so sad".
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 -> Mainframe Interview Questions

 


Similar Topics
Topic Forum Replies
No new posts How to give complex condition in JCL . CLIST & REXX 30
No new posts selectively copy based on condition DFSORT/ICETOOL 3
This topic is locked: you cannot edit posts or make replies. Control-m JOB executing even when the... Compuware & Other Tools 6
No new posts Dynamic condition checks COBOL Programming 5
No new posts Extract 2 more lines below line that ... DFSORT/ICETOOL 2
Search our Forums:

Back to Top