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

Condition code question


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

New User


Joined: 21 Sep 2008
Posts: 1
Location: india

PostPosted: Tue Dec 08, 2009 12:20 pm
Reply with quote

hi,

I have a situation where i need to execute a step in a proc only if the file name starts with value=ICLP; in the JCL there is a symbolic parameter defined for the 1st qualifier of the file as ENV=ICLP.
So, when i tried to use

// IF (&ENV EQ 'ILT4') THEN
//ICL34ATC EXEC PGM=WCS2100
.....
it showed JCL error; could you help me how to do this?

thanks in advance
Back to top
View user's profile Send private message
expat

Global Moderator


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

PostPosted: Tue Dec 08, 2009 12:34 pm
Reply with quote

DO NOT add your topic at the end of an existing one. Learn how to start a new topic.

You can not use IF/THEN/ELSE logic to do what you need.
Back to top
View user's profile Send private message
neontech
Warnings : 1

New User


Joined: 08 Dec 2009
Posts: 11
Location: mumbai

PostPosted: Tue Dec 08, 2009 6:18 pm
Reply with quote

You can identify... using IF condition...
You will have to use listcat... to identify the first hlq and then based on that only you can skip the processing.. that is a lenghty process
Back to top
View user's profile Send private message
expat

Global Moderator


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

PostPosted: Tue Dec 08, 2009 6:20 pm
Reply with quote

neontech wrote:
You can identify... using IF condition...
You will have to use listcat... to identify the first hlq and then based on that only you can skip the processing.. that is a lenghty process

Please read the original post, and then explain how your response is of any help to the OP.
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: Tue Dec 08, 2009 10:18 pm
Reply with quote

Quote:
You can identify... using IF condition...
You will have to use listcat... to identify the first hlq and then based on that only you can skip the processing.. that is a lenghty process
Please stop posting "things" that have not been tested and are just wrong. . .

This is not some chat room or blog where people are encouraged to just "throw in" anything they feel like posting icon_sad.gif

d
Back to top
View user's profile Send private message
lalitsharma_77

New User


Joined: 29 Nov 2007
Posts: 10
Location: Pune

PostPosted: Tue Dec 08, 2009 11:48 pm
Reply with quote

Hi Sumeeta Nair,

The symbolics can be checked using IF/ELSE condition only in one case. If you pass a numeric value. I have tested this multiple times and it worked.

Thanks
Lalit
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Wed Dec 09, 2009 12:23 am
Reply with quote

Quote:
The symbolics can be checked using IF/ELSE condition only in one case. If you pass a numeric value. I have tested this multiple times and it worked.


bullsith

if You disagree on my comment
please post ...
the page of the manual with the reference to such behavior
the jcl You submitted,
the jes output
strong evidence that the IF statement worked according to Your thinking
( should hold in any IT court )
Back to top
View user's profile Send private message
lalitsharma_77

New User


Joined: 29 Nov 2007
Posts: 10
Location: Pune

PostPosted: Wed Dec 09, 2009 2:41 am
Reply with quote

Hi Enrico,

I have tested this again:

JOB: (CATALOG PROC IN JOB LOOKS LIKE)
Code:

//CONDIFPR EXEC CONDIFPR,   
//           C='1',         
//           Q='*'         


PROC:
Code:

//CONDIFPR PROC C=''                                     
//*                                                     
//*******************************************************
//COND01 IF &C = 1 THEN                                 
//STEP001  EXEC PGM=IDCAMS                               
//SYSOUT   DD SYSOUT=&Q                                 
//SYSPRINT DD SYSOUT=&Q                                 
//SYSUDUMP DD SYSOUT=&Q                                 
//SYSIN    DD DSN=..........................(........),DISP=SHR
//    ENDIF                                             


When I ran SCANTEST or JCLB or !JCK (the command used to check the syntax) it gave me following result without any warning as well as errors. When I submitted it ran fine and I created a GDG base.

//***********************************************************
//CONDIFPR EXEC CONDIFPR,
// C='1',
// Q='*'
P1//CONDIFPR PROC C=''
P1//*
P1//*********************************************************
P1//COND01 IF &C = 1 THEN
P1--COND01 IF 1 = 1 THEN
P1//STEP001 EXEC PGM=IDCAMS
P1//SYSOUT DD SYSOUT=&Q
P1--SYSOUT DD SYSOUT=*
P1//SYSPRINT DD SYSOUT=&Q
P1--SYSPRINT DD SYSOUT=*
P1//SYSUDUMP DD SYSOUT=&Q
P1--SYSUDUMP DD SYSOUT=*


I have never gone through any manual so cannot show you in that. But I am sure it works as this is working in PROD region daily.

Thanks
Lalit
Back to top
View user's profile Send private message
superk

Global Moderator


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

PostPosted: Wed Dec 09, 2009 3:33 am
Reply with quote

In my shop (z/OS V1R9) it works at you'd expect. First, our !JCK says that that's an error:

//CONDIFPR EXEC CONDIFPR,
// C='1',
// Q='*'
XXCOND01 IF &C = 1 THEN
SUBST JCL - 1 = 1 THEN
CAY6037E UNKNOWN KEYWORD "1" SPECIFIED IN OPERAND OF "IF"

and the job ALWAYS executes STEP001 no matter what the value of 'C' is set to (as long as it's numeric).
Back to top
View user's profile Send private message
lalitsharma_77

New User


Joined: 29 Nov 2007
Posts: 10
Location: Pune

PostPosted: Wed Dec 09, 2009 3:46 am
Reply with quote

Hi Kevin,

Yes, when I tried '2' that time also it executed IDCAMS and created the GDG base.

Does this means that IF condition works with any numeric value passed as in symbolic and it never checks the value because in our region it is working fine. Right now we do have only one value and we might increase thsi number?

Thanks
Lalit
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


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

PostPosted: Wed Dec 09, 2009 4:24 am
Reply with quote

There is a manuals link at the top of the page. The JCL Language Reference manual includes
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 &C is not RC, ABEND, ¬ABEND, ABENDCC, RUN, or ¬RUN your use of it in an IF test in JCL is neither intended nor supported by IBM. In other words, it may not do what you think it does, and if you get results other than what you think you should -- good luck because IBM isn't going to help you get it working the way you think it should.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Wed Dec 09, 2009 4:43 am
Reply with quote

Hi Lalit!

I just tested Your sample, and it works icon_cry.gif

seems to rely on the fact that 1 = 1 is a logical expression for which no variable evaluation must be performed
looks like a bug of the converter/interpreter

I would define it against any good practices and official IBM docs

I believe that the approach even if working would not pass any audit nor quality assurance
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: Wed Dec 09, 2009 8:08 pm
Reply with quote

Hi Enrico,

Quote:
nor quality assurance
Depends on what the organization considers QA. . . icon_smile.gif

One place i supported had a QA policy that if a module was compiled more than 30 days ago it could no longer be promoted. . . Not only did the compile have to be recent, but all of the testing results had to be after the compile (which does make sense). . .

I guess the code got "grubby" sitting in the libraries - untouched . . .

d
Back to top
View user's profile Send private message
superk

Global Moderator


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

PostPosted: Wed Dec 09, 2009 8:19 pm
Reply with quote

I'm just curious about the discrepancies between our systems, why it works on some and not on others.
Back to top
View user's profile Send private message
lalitsharma_77

New User


Joined: 29 Nov 2007
Posts: 10
Location: Pune

PostPosted: Wed Dec 09, 2009 10:57 pm
Reply with quote

Hi Superk/Enrico/Robert/Dick,

You guys are my life saver icon_smile.gif. I do agree that &C (or other symbolics) are not frequently used as compare to ABEND and RC. I will definitly go through all the possible manauls to look into this again.

Thanks a lot for your directions.
Back to top
View user's profile Send private message
lalitsharma_77

New User


Joined: 29 Nov 2007
Posts: 10
Location: Pune

PostPosted: Wed Dec 09, 2009 11:47 pm
Reply with quote

Hi Moderators,

I moved 1 step ahead from this point. I modified my job (same job above) to execute 2 steps depending upon symbolic passed using IF/THEN and ELSE. The executed both the steps icon_sad.gif. So far my understanding is, it is not a good practice to use IF/THEN/ELSE with symbolics.

Thanks
Lalit
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: Thu Dec 10, 2009 12:37 am
Reply with quote

Hello,

Quote:
why it works on some and not on others
And with which upgrade or ptf the behavior might change. . .
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 run rexx code with jcl CLIST & REXX 15
No new posts Compile rexx code with jcl CLIST & REXX 6
No new posts REXX code to expand copybook in a cob... CLIST & REXX 2
No new posts Question for file manager IBM Tools 7
No new posts VSAM return code 23 - for a Random read COBOL Programming 4
Search our Forums:

Back to Top