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

Evaluate staement with "OR"


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: Mon Jul 04, 2011 12:43 pm
Reply with quote

Hi,

want to check multiple values in single when statement in as below
Code:


EVALUATE FUNCTION NUMVAL(OUTFILE-xxx) 
         ALSO                         
         FUNCTION NUMVAL(OUTFILE-yyy)
when 14 or 01 or 50 also any
WHEN 10 ALSO (20 OR 50 OR 20 OR 50 OR 70)           
WHEN 11 ALSO (1 OR 2 OR 20 OR 2102 OR 309 OR 30 OR       
               4 OR 640 OR 457 OR 50 OR 51 OR 55 OR 
               60 OR 75 OR 80)                         
WHEN 2 ALSO (81 OR 82)     
end-evaluate

                           

I receive the following error in the above code
Code:

 IGYPS2048-S   An invalid abbreviated relation condition was found


Please help me to fix the above error thanks
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Mon Jul 04, 2011 1:08 pm
Reply with quote

OR connectives with respect to EVALUATE are

WHEN A
WHEN B
instead of
WHEN A OR B

Also, you have not included all of the EVALUATE statement,
so how do you expect us to help?

experienced programmers also use the WHEN OTHER to trap unexpected values and handle the exceptions appropriately.

Personally, I would have FUNCTION NUMVAL()'d to two fields,
with level 88's.

then the EVALUATE would have been much simpler to code - and analyze.
Back to top
View user's profile Send private message
UmeySan

Active Member


Joined: 22 Aug 2006
Posts: 771
Location: Germany

PostPosted: Mon Jul 04, 2011 1:31 pm
Reply with quote

Hi !

Ther's also the possibility of using THRU to handle a numeric range.

Evaluate Wrk-Field
...When 1 thru 9 perform ...
...When other continue
End-Evaluate
Back to top
View user's profile Send private message
paduchuri

New User


Joined: 03 Jan 2011
Posts: 32
Location: Hyderabad

PostPosted: Mon Jul 04, 2011 1:35 pm
Reply with quote

Hi UmeySan,

I this case it may not be effective since my values are not sequencial they are random.

Thanks for your reply
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Mon Jul 04, 2011 1:41 pm
Reply with quote

I am not a cobol expert, but in general when the number of values to check is <large>
it would be wise to use an ordered list with a less than comparison to check for a missing value

I am not telling you to use an ordered list but just to meditate on the general searching/matching issue
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: Mon Jul 04, 2011 2:31 pm
Reply with quote

Code:
01  W-OUTFILE-XXX-TYPE PIC 9.
88 W-OUTFILE-XXX-TYPE-IS-OPEN VALUE 1, 2, 3.
88 W-OUTFILE-XXX-TYPE-IS-CLOSE VALUE 4.
88 W-OUTFILE-XXX-TYPE-IS-SUSPEND VALUE 5.
88 W-OUTFILE-XXX-TYPE-IS-MANUAL-EXCEPTION VALUE 9.


01  W-OUTFILE-YYY-TYPE PIC 9(4).
88 W-OUTFILE-YYY-TYPE-IS-CLOSE-DETAIL VALUE 1, 2.
88 W-OUTFILE-YYY-TYPE-IS-SUSPEND-DETAIL VALUE 20, 50.
88 W-OUTFILE-YYY-TYPE-IS-MANUAL-EXCEPTION-DETAIL VALUE 81, 82.     


Code:
COMPUTE W-OUTFILE-XXX-TYPE = FUNCTION NUMVAL(OUTFILE-xxx)
COMPUTE W-OUTFILE-YYY-TYPE = FUNCTION NUMVAL(OUTFILE-yyy)

...
WHEN W-OUTFILE-XXX-TYPE-IS-OPEN
  ALSO ANY
do open stuff
WHEN W-OUTFILE-XXX-TYPE-IS-CLOSE
  ALSO W-OUTFILE-YYY-TYPE-IS-CLOSE-DETAIL
do close stuff
WHEN W-OUTFILE-XXX-TYPE-IS-SUSPEND
  ALSO W-OUTFILE-YYY-TYPE-IS-SUSPEND-DETAIL
do suspend stuff
WHEN W-OUTFILE-XXX-TYPE-IS-MANUAL-EXCEPTION
  ALSO W-OUTFILE-YYY-TYPE-IS-MANUAL-EXCEPTION-DETAIL
do manual exception stuff
WHEN OTHER
  ALSO ANY
do illlogical code combination stuff
END-EVALUATE


This, like dbz suggests, is orders of magnitude easier to follow, for you or anyone else.

I don't know why you feel you need to make them numeric, either, but maybe there's a good reason.

Are the repeated values in your 2nd when typos?
Back to top
View user's profile Send private message
paduchuri

New User


Joined: 03 Jan 2011
Posts: 32
Location: Hyderabad

PostPosted: Mon Jul 04, 2011 3:01 pm
Reply with quote

Thanks for your suggesssion

logo codes repeated not typo.

I just used numval bacause the logo filed is 8 byte long char field.

eg 0 will be '0 '
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Mon Jul 04, 2011 3:19 pm
Reply with quote

Quote:
(20 OR 50 OR 20 OR 50 OR 70)


20 or 50 or 20 or 50

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

New User


Joined: 03 Jan 2011
Posts: 32
Location: Hyderabad

PostPosted: Mon Jul 04, 2011 3:30 pm
Reply with quote

sorry guys its just typo.

Thanks for correcting me.
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: Mon Jul 04, 2011 3:42 pm
Reply with quote

paduchuri wrote:
[...]
logo codes repeated not typo.

I just used numval bacause the logo filed is 8 byte long char field.

eg 0 will be '0 '


I also don't undestand what you want deliberate repitition for. There is no point to it.

There is no problem with coding "0 " etc on your VALUE statement. NUMVAL would treat "1,000" and "1000", for example, as the same. Obviously possibilities for the field, and whether these are equivalent, are known to you. But if you are just messing with a field for a test to make it less typing for you, you are asking for trouble somewhere along the way.
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 PuTTY - "User is not a surrogate... IBM Tools 5
No new posts Newbie Stuck on "Duplicate Datas... TSO/ISPF 5
No new posts Evaluate variable to execute a jcl step JCL & VSAM 3
No new posts RABBIT HOLE NEEDED - "Live"... All Other Mainframe Topics 0
No new posts Using PARM=('JPn"&SYMBOL&quo... DFSORT/ICETOOL 2
Search our Forums:

Back to Top