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

IF Then ELSE in JCL


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

New User


Joined: 11 Oct 2004
Posts: 69
Location: chennai

PostPosted: Mon Jan 31, 2011 12:26 pm
Reply with quote

Hi,

I am passing two parameters in a PROC and based on those parameters I need to execute my steps in a JCL.My Proc has following steps:
// PROC AVT=,AVT1=
// IF &AVT=1 THEN
//STEP2 EXEC PGM=SAMPLE5
//STEPLIB DD DSN=TEST.COBOL.LOAD,DISP=SHR
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSIN DD DUMMY
// ENDIF

// IF &AVT1=2 THEN
//STEP3 EXEC PGM=SAMPLE6
//STEPLIB DD DSN=TEST.COBOL.LOAD,DISP=SHR
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSIN DD DUMMY
// ENDIF

My Job is:
//ABC JOB LASS=E,MSGCLASS=U,REGION=0M,NOTIFY=&SYSUID
//PROCLIB JCLLIB ORDER=TEST.SOURCE.JCL
//STEP01 EXEC IFTHENJ,AVT=1,AVT1=3

If I pass a different value for AVT1 variable other than 2 then my first step is executed and the next one is not executing as the condition is not satisfied Whereas when i change the value as AVT=3,AVT1=2 then both the steps are executed.
When the condition is AVT=3,AVT1=2 only my second condition should be executed.Please suggest
Back to top
View user's profile Send private message
expat

Global Moderator


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

PostPosted: Mon Jan 31, 2011 1:58 pm
Reply with quote

What does it say in the JCL reference manual, easily reached by clicking the "IBM Manuals" button at the top of any page, about defining your own variables for comparison.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Mon Jan 31, 2011 9:41 pm
Reply with quote

Hello,

Quote:
Please suggest
Suggest you use a different approach. . .
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Tue Feb 01, 2011 3:13 am
Reply with quote

This might be a crazy WAG, but insert (as your first step in the PROC before any) an IDCAMS which issues a SET MAXCC=0. This statement needs to be assigned to //SYSIN as a PDS member or sequential file, because //SYSIN DD * stream data is not allowed in a PROC.

Give it a try....

Bill
Back to top
View user's profile Send private message
Jeffrey Ranney

New User


Joined: 23 Dec 2010
Posts: 20
Location: USA

PostPosted: Tue Feb 08, 2011 5:09 pm
Reply with quote

You cannot SET your own variables for testing in a JCL "IF" condition, as explained in the JCL manual. You can only test RETURN-CODEs of a particular step or of the entire job.
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Wed Feb 09, 2011 7:17 am
Reply with quote

In addition to issuing an IDCAMS SET MAXCC=0 before executing any step, review the following, as it does work -

ibmmainframes.com/viewtopic.php?p=258902&highlight=#258902

Bill
Back to top
View user's profile Send private message
krishna rao M

New User


Joined: 10 Feb 2011
Posts: 9
Location: India

PostPosted: Mon Feb 14, 2011 12:33 am
Reply with quote

Hi
i think first step should not have if condition
try it like this

// PROC AVT=,AVT1=
//STEP1 EXEC PGM=DISP
//STEPLIB DD DSN=T91IPRR.RAVEENDR.COBOL.LOADLIB,DISP=SHR
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSIN DD DUMMY

// IF &AVT=1 THEN
//STEP2 EXEC PGM=DISP
//STEPLIB DD DSN=T91IPRR.RAVEENDR.COBOL.LOADLIB,DISP=SHR
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSIN DD DUMMY
// ENDIF

// IF &AVT1=2 THEN
//STEP3 EXEC PGM=DISP
//STEPLIB DD DSN=T91IPRR.RAVEENDR.COBOL.LOADLIB,DISP=SHR
//SYSPRINT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSIN DD DUMMY
// ENDIF

you can pass different values and check it
please acknowledge me
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Mon Feb 14, 2011 12:46 am
Reply with quote

Hello and welcome to the forum,

Did you test using &AVT= the way you have shown?

If not, do so and post the result.
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: Mon Feb 14, 2011 12:52 am
Reply with quote

krishna rao, did you not read the previous posts in this thread? The JCL Reference manual explicitly states:
Quote:
17.1.4.5 Relational-Expression Keywords


The following keywords are the only keywords supported by IBM and recommended for use in relational-expressions. Any other keywords, even if accepted by the system, are not intended or supported keywords.

Keyword Use
RC
indicates a return code
ABEND
indicates an abend condition occurred
¬ABEND
indicates no abend condition occurred
ABENDCC
indicates a system or user completion code
RUN
indicates that the specified step started execution
¬RUN
indicates that the specified step did not start execution
Since &AVT is not RC, ABEND, nor any of the other supported keywords -- whether or not your JCL is accepted by the system, the IF statement is not a valid construct and may not be interpreted in the way you think. As was hinted -- and stated -- in earlier posts, you are not allowed to make up your own IF statements in JCL. You must use only the allowed keywords or the JCL will, at best, run unpredictably, and at worst not run at all.
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

 


Search our Forums:

Back to Top