Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

How to add the condition in if statement

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> PL/I & Assembler
View previous topic :: :: View next topic  
Author Message
Prabha
Warnings : 2

New User


Joined: 05 Dec 2005
Posts: 79

PostPosted: Mon Jan 28, 2008 4:17 pm    Post subject: How to add the condition in if statement
Reply with quote

Hi,

Below is the esisting code

IF AK402AA19 = 'MAXI '
& AK402AA24 = 'Y'
| (AK402AA19 = 'MINIE'
| AK402AA19 = 'MINIC'
| AK402AA19 = 'MINIL')
& AK402AA23 = 'Y'
THEN
G387EA01 = 3716;
END;

Here if AK402aa19 is MAXI, AK402aa24 is 'Y', Ak402AAA23 is 'y' means, 3716 will be assigned.

Now, i need to add more checking, that ak4022aa20 >=892.
IF AK402AA19 = 'MAXI '
& AK402AA24 = 'Y'
| (AK402AA19 = 'MINIE'
| AK402AA19 = 'MINIC'
| AK402AA19 = 'MINIL')
& AK402AA23 = 'Y'
&Ak4022A20 >=892
THEN
G387EA01 = 3716;
END;

Here if AK402aa19 is MAXI, AK402aa24 is 'Y', Ak402AAA23 is 'y' and Ak402AA20 is 891 means, it should not assign 3716. But my code assigns the value 3716.

Help me how to add the condition AK402AA >=892
Back to top
View user's profile Send private message

enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10254
Location: italy

PostPosted: Mon Jan 28, 2008 5:00 pm    Post subject: Reply to: How to add the condition in if statement
Reply with quote

...
use the code tag to make Your code more readable
for complex logic expressions in the if
it would be better to use parenthesis !
if You had used them the operators precedences would have been more clear
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10254
Location: italy

PostPosted: Mon Jan 28, 2008 5:02 pm    Post subject: Reply to: How to add the condition in if statement
Reply with quote

the parenthese were there icon_biggrin.gif

not using the code tag didn' t make them stick out !!
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10254
Location: italy

PostPosted: Mon Jan 28, 2008 5:13 pm    Post subject: Reply to: How to add the condition in if statement
Reply with quote

I keep hitting the enter key too early..

I see You are using parenthesis in the most unclear way...

expression without parenthesis should be used only for operators with the same precedence level

Your way of writing, in many places I have known, would not have passed quality assurance

for example :
Code:

A & B & C   is ok all &
A | B | C    same

Code:

A & B | C   ??? without looking at the manual

( A & B ) | C
A & ( B | C )

the reader with a different programming language background
would have to look at the manual to find the proper operator priority
Back to top
View user's profile Send private message
dick scherrer

Site Director


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

PostPosted: Mon Jan 28, 2008 9:09 pm    Post subject:
Reply with quote

Hello,

Your problem may be with the first "or".

Quote:
& AK402AA24 = 'Y'
| (AK402AA19 = 'MINIE'


I believe that should be an "&".

I'd sugest you verify which values ahould be "and'ed" and which values should be "or'ed".
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> PL/I & Assembler All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
This topic is locked: you cannot edit posts or make replies. Need help on If condition continuatio... ashok_uddaraju CLIST & REXX 4 Fri May 19, 2017 8:55 am
No new posts Joinkeys with condition scdinesh DFSORT/ICETOOL 10 Tue Feb 14, 2017 12:20 am
No new posts ROUNDED Problem with COMPUTE statement shalem COBOL Programming 11 Thu Feb 09, 2017 8:16 pm
No new posts VALIDATE NULL VALUE IN DB2 CASE STATE... useit DB2 5 Thu Feb 09, 2017 4:34 pm
No new posts -913/-911 Deadlock during UPDATE stat... NoSleep319 DB2 5 Fri Nov 18, 2016 12:37 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us