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 staement with "OR"

 
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: Mon Jul 04, 2011 12:43 pm    Post subject: Evaluate staement with "OR"
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    Post subject:
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: 743
Location: Germany

PostPosted: Mon Jul 04, 2011 1:31 pm    Post subject:
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    Post subject: Reply to: Evaluate staement with "OR"
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Mon Jul 04, 2011 1:41 pm    Post subject: Reply to: Evaluate staement with "OR"
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7232

PostPosted: Mon Jul 04, 2011 2:31 pm    Post subject: Re: Evaluate staement with "OR"
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    Post subject: Reply to: Evaluate staement with "OR"
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    Post subject:
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    Post subject: Reply to: Evaluate staement with "OR"
Reply with quote

sorry guys its just typo.

Thanks for correcting me.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7232

PostPosted: Mon Jul 04, 2011 3:42 pm    Post subject: Re: Reply to: Evaluate staement with "OR"
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    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 Amount field is getting corrupted whe... thesumitk SYNCSORT 5 Tue Oct 18, 2016 8:20 pm
No new posts hot to get details when "EXEC CI... Andi1982 CICS 11 Tue Sep 20, 2016 5:01 pm
No new posts Multi row fetch - "for read only... Nileshkul DB2 3 Sun Aug 14, 2016 12:52 am
No new posts "DFSRRC00 vs IKJEFT01" for ... arunsoods All Other Mainframe Topics 5 Fri Aug 12, 2016 9:54 pm
No new posts Need to show date in "DYYMMDD.TH... deepak_shrivastava DFSORT/ICETOOL 2 Tue Jan 05, 2016 7:15 pm


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