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

How to add the condition in if statement


IBM Mainframe Forums -> PL/I & Assembler
Post new topic   Reply to topic
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
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

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Mon Jan 28, 2008 5:00 pm
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

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Mon Jan 28, 2008 5:02 pm
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

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Mon Jan 28, 2008 5:13 pm
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

Moderator Emeritus


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

PostPosted: Mon Jan 28, 2008 9:09 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> PL/I & Assembler

 


Similar Topics
Topic Forum Replies
No new posts JOIN STATEMENT PERFORMANCE. DFSORT/ICETOOL 12
No new posts How to give complex condition in JCL . CLIST & REXX 30
No new posts Relate COBOL statements to EGL statement All Other Mainframe Topics 0
No new posts selectively copy based on condition DFSORT/ICETOOL 3
No new posts process statement for SUPREC, CMPCOLM... TSO/ISPF 4
Search our Forums:

Back to Top