View previous topic :: View next topic
|
Author |
Message |
paduchuri
New User
Joined: 03 Jan 2011 Posts: 32 Location: Hyderabad
|
|
|
|
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 |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
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 |
|
|
UmeySan
Active Member
Joined: 22 Aug 2006 Posts: 771 Location: Germany
|
|
|
|
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 |
|
|
paduchuri
New User
Joined: 03 Jan 2011 Posts: 32 Location: Hyderabad
|
|
|
|
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 |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
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 |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
|
paduchuri
New User
Joined: 03 Jan 2011 Posts: 32 Location: Hyderabad
|
|
|
|
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 |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
Quote: |
(20 OR 50 OR 20 OR 50 OR 70) |
20 or 50 or 20 or 50
is repeated...................................................... |
|
Back to top |
|
|
paduchuri
New User
Joined: 03 Jan 2011 Posts: 32 Location: Hyderabad
|
|
|
|
sorry guys its just typo.
Thanks for correcting me. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
|
|