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

evaluate statement with not operator


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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: 2481
Location: Netherlands, Amstelveen

PostPosted: Wed May 18, 2011 1:25 pm
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
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: 2481
Location: Netherlands, Amstelveen

PostPosted: Wed May 18, 2011 2:36 pm
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
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed May 18, 2011 2:58 pm
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
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
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: 121
Location: Puerto Rico

PostPosted: Wed May 18, 2011 7:43 pm
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
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

Moderator Emeritus


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

PostPosted: Wed May 18, 2011 11:35 pm
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: 8700
Location: Dubuque, Iowa, USA

PostPosted: Thu May 19, 2011 12:11 am
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
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
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu May 19, 2011 2:33 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts JOIN STATEMENT PERFORMANCE. DFSORT/ICETOOL 12
No new posts Evaluate variable to execute a jcl step JCL & VSAM 3
No new posts Relate COBOL statements to EGL statement All Other Mainframe Topics 0
No new posts process statement for SUPREC, CMPCOLM... TSO/ISPF 4
No new posts SYNCSORT/ICETOOL JOINKEYS SORT Statem... DFSORT/ICETOOL 13
Search our Forums:

Back to Top