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
 

 

evaluate statement with not operator

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
paduchuri

New User


Joined: 03 Jan 2011
Posts: 32
Location: Hyderabad

PostPosted: Wed May 18, 2011 1:02 pm    Post subject: evaluate statement with not operator
Reply with quote

Hi All,

I am strucked up in evaluate statement.I am not able to use multiple not in a when condition.see below example

Code:

EVALUATE PIM
when 100
dispaly 'temp1'
when 200
dispaly 'temp2'
when not 120
dispaly 'temp3'     
WHEN ( NOT 200 AND NOT 500 )  /*not working here*/       
DISPLAY 'temp5'
END-EVALUATE.                         

i am getting the following error message
Code:

28  IGYPS2048-S   An invalid abbreviated relation condition was found.

Please can some one advise me how to use muliple not in a when condition

Regards,
Pavan.
Back to top
View user's profile Send private message

PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2422
Location: Netherlands, Amstelveen

PostPosted: Wed May 18, 2011 1:25 pm    Post subject:
Reply with quote

try this :

when not 200
when not 500
display 'temp5'
Back to top
View user's profile Send private message
paduchuri

New User


Joined: 03 Jan 2011
Posts: 32
Location: Hyderabad

PostPosted: Wed May 18, 2011 2:26 pm    Post subject: Reply to: evaluate statement with not operator
Reply with quote

As per my actual requirement ,number of when's will increase in that case so i am just wondering if there is any alternative

Regards,
pavan.
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2422
Location: Netherlands, Amstelveen

PostPosted: Wed May 18, 2011 2:36 pm    Post subject:
Reply with quote

nope.
Back to top
View user's profile Send private message
paduchuri

New User


Joined: 03 Jan 2011
Posts: 32
Location: Hyderabad

PostPosted: Wed May 18, 2011 2:55 pm    Post subject: Reply to: evaluate statement with not operator
Reply with quote

Code:

EVALUATE PIM also pim1
when 100 also 200
dispaly 'temp1'
when 200 also 500
dispaly 'temp2'
when not 120 also 300
dispaly 'temp3'     
WHEN ( NOT 200 AND NOT 500 ) also 200  /*not working here*/       
DISPLAY 'temp5'
END-EVALUATE.

in the above case i cannot apply your method please advise
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Wed May 18, 2011 2:58 pm    Post subject: Reply to: evaluate statement with not operator
Reply with quote

Why not? "Nope" means no. Why are you worried about number of WHEN's?

Why don't you code it as a nested IF and forget the EVALUATE if you don't like it?
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed May 18, 2011 3:06 pm    Post subject:
Reply with quote

Pavan Kumar wrote:
in the above case i cannot apply your method please advise


if all else fails, read the manual.

EVALUATE
WHEN ??
WHEN ??
DO SOMETHING
WHEN ??
DO SOMETHING
END-EVALUATE

is the syntax that you were provided,
yet you failed to use it.

there is a limit of 256 WHEN's within a single evaluate.
are you going to reach that limit?
Back to top
View user's profile Send private message
nigelosberry

New User


Joined: 06 Jan 2009
Posts: 88
Location: Ggn, IN

PostPosted: Wed May 18, 2011 3:06 pm    Post subject: Re: evaluate statement with not operator
Reply with quote

How about writing it in a different manner?
i.e.

EVALUATE TRUE
...
....
WHEN PIM NOT = 200 OR 500
END-EVALUATE
Back to top
View user's profile Send private message
Jose Mateo

Active User


Joined: 29 Oct 2010
Posts: 110
Location: Puerto Rico

PostPosted: Wed May 18, 2011 7:43 pm    Post subject:
Reply with quote

Good day to all!

Try this one;
EVALUATE PIM
when 100
dispaly 'temp1'
when 200 <------ Anything after this condition is NOT 200
dispaly 'temp2'
when not 120
dispaly 'temp3' <---Everything that is not 120 will end here
WHEN NOT 500 <--- At this point everything will be 120
DISPLAY 'temp5' <--- all 120
END-EVALUATE.

Is this what you want to do? I don't think so.
Back to top
View user's profile Send private message
paduchuri

New User


Joined: 03 Jan 2011
Posts: 32
Location: Hyderabad

PostPosted: Wed May 18, 2011 8:36 pm    Post subject: Reply to: evaluate statement with not operator
Reply with quote

Thanks to every one for your solutions.

Finally i want to go with nihalansari approach.

EVALUATE TRUE
...
....
WHEN PIM NOT = 200 OR 500
END-EVALUATE.
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: Wed May 18, 2011 11:35 pm    Post subject:
Reply with quote

Hello,

Has this been tested?

If the statement were an IF with a NOT/OR it would fail - every value would be not= to one or the other. I'm not sure about EVALUATE/WHEN and am not able to test this just now. . .
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7904
Location: Bellevue, IA

PostPosted: Thu May 19, 2011 12:11 am    Post subject:
Reply with quote

Quote:
WHEN PIM NOT = 200 OR 500
DeMorgan's Laws. If PIM is 200, it is not 500. If PIM is 500, it is not 200. If PIM is anything else, it is not 200 nor 500. In other words, this IF test will always evaluate true, no matter what the value of PIM. Not to mention that this IF statement is NOT the equivalent of the o/p code.

Code:
EVALUTE TRUE
WHEN PIM NOT = 200 AND PIM NOT = 500
is recommended to ensure those who come after will thoroughly understand the logic -- allowing implied conditions when using NOT is just begging for maintenance problems down the line.
Back to top
View user's profile Send private message
nigelosberry

New User


Joined: 06 Jan 2009
Posts: 88
Location: Ggn, IN

PostPosted: Thu May 19, 2011 9:39 am    Post subject:
Reply with quote

dick scherrer wrote:
Hello,

Has this been tested?

If the statement were and IF with a NOT/OR it would fail - every value would be not= to one or the other. I'm not sure about EVALUATE/WHEN and am not able to test this just now. . .



Yes, that's right, Thanks!

Syntactically its correct to have OR there but it will not serve the purpose. I think the OR should be replaced by AND
something like:

Code:
WHEN PIM NOT = 200 AND 500
      display ' not 200 AND not 500'
Back to top
View user's profile Send private message
nigelosberry

New User


Joined: 06 Jan 2009
Posts: 88
Location: Ggn, IN

PostPosted: Thu May 19, 2011 9:44 am    Post subject:
Reply with quote

I have created a test program and compiled(Not tested with real data but I feel it should do):


Code:
WORKING-STORAGE SECTION.   
....                           
01 PIM PIC S9(03) COMP-3.   
.....
PROCEDURE DIVISION.                   
....
....                                       
    EVALUATE TRUE                     
    ....
    ....
    WHEN PIM NOT = 200 AND 500         
       DISPLAY 'NOT 200 AND NOT 500'   
    END-EVALUATE

and the assembler listing for this says:

Code:
000038  WHEN                                                                   
   000488  F911 8028 A0A4          CP    40(2,8),164(2,10)       PIM           
   00048E  4780 B1F0               BC    8,496(0,11)             GN=12(0004A0) 
   000492  F911 8028 A0A0          CP    40(2,8),160(2,10)       PIM           
   000498  4780 B1F0               BC    8,496(0,11)             GN=12(0004A0) 
   00049C  47F0 B1F4               BC    15,500(0,11)            GN=24(0004A4) 
   0004A0                 GN=12    EQU   *                                     
   0004A0  47F0 B1FE               BC    15,510(0,11)            GN=23(0004AE) 
   0004A4                 GN=24    EQU   *                                     
000039  DISPLAY                                                                 
   0004A4  58F0 202C               L     15,44(0,2)              V(IGZCDSP )   
   0004A8  4110 A130               LA    1,304(0,10)             PGMLIT AT +296
   0004AC  0DEF                    BASR  14,15                                 
   0004AE                 GN=23    EQU   *                                     
   0004AE                 GN=16    EQU   *                                     



Its look ok to me. Let me know if something's missing as I HAVE NOT TESTED IT.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Thu May 19, 2011 2:33 pm    Post subject:
Reply with quote

nihalansari wrote:
I have created a test program and compiled(Not tested with real data but I feel it should do):


Code:
WORKING-STORAGE SECTION.   
....                           
01 PIM PIC S9(03) COMP-3.   
.....
PROCEDURE DIVISION.                   
....
....                                       
    EVALUATE TRUE                     
    ....
    ....
    WHEN PIM NOT = 200 AND 500         
       DISPLAY 'NOT 200 AND NOT 500'   
    END-EVALUATE

and the assembler listing for this says:

Code:
000038  WHEN                                                                   
   000488  F911 8028 A0A4          CP    40(2,8),164(2,10)       PIM           
   00048E  4780 B1F0               BC    8,496(0,11)             GN=12(0004A0) 
   000492  F911 8028 A0A0          CP    40(2,8),160(2,10)       PIM           
   000498  4780 B1F0               BC    8,496(0,11)             GN=12(0004A0) 
   00049C  47F0 B1F4               BC    15,500(0,11)            GN=24(0004A4) 
   0004A0                 GN=12    EQU   *                                     
   0004A0  47F0 B1FE               BC    15,510(0,11)            GN=23(0004AE) 
   0004A4                 GN=24    EQU   *                                     
000039  DISPLAY                                                                 
   0004A4  58F0 202C               L     15,44(0,2)              V(IGZCDSP )   
   0004A8  4110 A130               LA    1,304(0,10)             PGMLIT AT +296
   0004AC  0DEF                    BASR  14,15                                 
   0004AE                 GN=23    EQU   *                                     
   0004AE                 GN=16    EQU   *                                     



Its look ok to me. Let me know if something's missing as I HAVE NOT TESTED IT.


Yes, from the code it is operating as you say.

Whenever I code a "complex" condition, I always use parentheses. Here, I know that the NOT applies to both left and right of the condition, if I do this.

Code:

WHEN PIM NOT = ( 200 AND 500 )
       DISPLAY 'NOT 200 AND NOT 500'   
    END-EVALUATE


Otherwise, the compiler will always do something, and I'll have to think hard (or check) what it is the compiler does. Put in the parentheses, and you no longer have to worry that the compiler might not understand what you want.
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 -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts -913/-911 Deadlock during UPDATE stat... NoSleep319 DB2 5 Fri Nov 18, 2016 12:37 am
No new posts COBOL DB2 - CALL statement - high CPU... TS70363 DB2 15 Sun Sep 11, 2016 6:07 am
No new posts Converting NULL column into NOT NULL ... Raghu navaikulam DB2 5 Sat Aug 06, 2016 3:45 pm
This topic is locked: you cannot edit posts or make replies. Updating value of key using rewrite s... ParminderKumar COBOL Programming 4 Thu Aug 04, 2016 12:46 am
No new posts Inspect statement spoorni COBOL Programming 5 Mon Jun 06, 2016 9:53 pm


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