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

Strange results from IF THEN ELSE


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Captain Paralytic
Warnings : 1

New User


Joined: 21 Apr 2010
Posts: 40
Location: UK

PostPosted: Thu Sep 23, 2010 7:15 pm
Reply with quote

mtaylor wrote:
Thanks for uncovering this nice little tid bit. I don't recall if I coded my JCL parser to accept an IF as the first statement in a job or not, I'll have to check. Although now that I think about it, there may be verbage in the manual to specify IF may not be first in a job.

Note; I also prefer the OS 390 JCL manual over any of the Z/OS ones. They rewrote and obfuscated a lot of relavent information in the newer manuals.


I am just writing some feedback for the manual since, as pointed out by other posters in this thread, the list of what may be in a relational-expression is not compete. It states
Quote:
A relational-expression consists of:
  • Comparison operators
  • Logical operators
  • NOT (¬) operators
  • Relational-expression keywords.
But it does not state that it may also contain:
  • Integer constants (e.g. 04, 08)
  • Boolean constants (TRUE, FALSE)
which it quite plainly does.
Back to top
View user's profile Send private message
nil_mf

New User


Joined: 06 Jun 2005
Posts: 29

PostPosted: Thu Sep 23, 2010 7:30 pm
Reply with quote

Hi Captain,

Can you please check the below link

publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/iea2b600/17.1.9?SHELF=&DT=20010117171733&CASE=

Here it is mentioned

"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.
"

Nil
Back to top
View user's profile Send private message
Captain Paralytic
Warnings : 1

New User


Joined: 21 Apr 2010
Posts: 40
Location: UK

PostPosted: Thu Sep 23, 2010 7:53 pm
Reply with quote

nil_mf wrote:

"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.
Yes, but as we have seen, this statement is not correct! The IF statement DOES get evaluated when the relational-expression is true.

I would expect consistency. Either the statement is NOT evaluated so that both the THEN and ELSE part are always executed, regardless of the logical value of the relational-expression, or it is always evaluated.

What we are seeing is that the relational-expression is evaluated and if its result is TRUE, then the IF statement operates in the normal way for an IF statement, but if the result is FALSE, the steps are executed as if the IF statement is not there.
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: Thu Sep 23, 2010 8:00 pm
Reply with quote

The IF statement is not evaluated, hence STEP1 executes.

The IF evaluation is done to determine whether or not to perform STEP2 -- per the manual statement nil_mf quoted. If the evaluation is such that the ELSE condition is selected, STEP2 executes. If the ELSE condition is not selected, STEP2 does not execute. So either the first step or both steps will be executed, depending upon the IF condition.

The manual statement from nil_mf, applied to your example, has predictable and understandable results.
Back to top
View user's profile Send private message
Phrzby Phil

Senior Member


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

PostPosted: Fri Sep 24, 2010 6:14 pm
Reply with quote

So - you guys gonna have that beer now?
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 DB2 Statistics - Using EXPLAIN and qu... DB2 1
No new posts Strange MNOTE related to BMS using PI... CICS 0
No new posts COBOL NOADVANCING strange results in ... COBOL Programming 4
No new posts partitioning row-num and aggregation ... DB2 0
No new posts How to extract the difference from Su... TSO/ISPF 3
Search our Forums:

Back to Top