View previous topic :: View next topic
|
Author |
Message |
Kamlesh Kamal
New User
Joined: 16 May 2008 Posts: 36 Location: Kolkata,India
|
|
|
|
Hi,
Can anyone confirm if this WHEN clause will work?
Code: |
EVALUATE TRUE
WHEN ((POOL-CD OF DCLTCMPRDCR-ERN-DTL = 'FYGB' OR
POOL-CD OF DCLTCMPRDCR-ERN-DTL = 'FYNB' OR
POOL-CD OF DCLTCMPRDCR-ERN-DTL = 'RENB' OR
POOL-CD OF DCLTCMPRDCR-ERN-DTL = 'RENN' OR
POOL-CD OF DCLTCMPRDCR-ERN-DTL = 'MAVG' OR
POOL-CD OF DCLTCMPRDCR-ERN-DTL = 'MLGA' OR
POOL-CD OF DCLTCMPRDCR-ERN-DTL = 'MGAN' OR
POOL-CD OF DCLTCMPRDCR-ERN-DTL = 'NPMF') OR
(SPEC-PSTN-CD OF DCLTCSEPIPRDCR(1:2)
NOT EQUAL TO '72' AND
(POOL-CD OF DCLTCMPRDCR-ERN-DTL = 'MAVF' OR
POOL-CD OF DCLTCMPRDCR-ERN-DTL = 'MAVR' OR
POOL-CD OF DCLTCMPRDCR-ERN-DTL = 'MGAF' OR
POOL-CD OF DCLTCMPRDCR-ERN-DTL = 'MGAR' OR
POOL-CD OF DCLTCMPRDCR-ERN-DTL = 'MLGF' OR
POOL-CD OF DCLTCMPRDCR-ERN-DTL = 'MLGR' OR
POOL-CD OF DCLTCMPRDCR-ERN-DTL = 'RNBF' OR
POOL-CD OF DCLTCMPRDCR-ERN-DTL = 'RNBR' OR
POOL-CD OF DCLTCMPRDCR-ERN-DTL = 'RNNF' OR
POOL-CD OF DCLTCMPRDCR-ERN-DTL = 'RNNR'))) |
I guess my requirement is clear from the where clause but the conditions of
Code: |
(SPEC-PSTN-CD OF DCLTCSEPIPRDCR(1:2)
NOT EQUAL TO '72' AND
(POOL-CD OF DCLTCMPRDCR-ERN-DTL = 'MAVF' OR
POOL-CD OF DCLTCMPRDCR-ERN-DTL = 'MAVR' OR
POOL-CD OF DCLTCMPRDCR-ERN-DTL = 'MGAF' OR
POOL-CD OF DCLTCMPRDCR-ERN-DTL = 'MGAR' OR
POOL-CD OF DCLTCMPRDCR-ERN-DTL = 'MLGF' OR
POOL-CD OF DCLTCMPRDCR-ERN-DTL = 'MLGR' OR
POOL-CD OF DCLTCMPRDCR-ERN-DTL = 'RNBF' OR
POOL-CD OF DCLTCMPRDCR-ERN-DTL = 'RNBR' OR
POOL-CD OF DCLTCMPRDCR-ERN-DTL = 'RNNF' OR
POOL-CD OF DCLTCMPRDCR-ERN-DTL = 'RNNR'))) |
are getting skipped---not checked.. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
What happens if the code only checks for NOT EQUAL TO '72'? Does this evaluate true? |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8697 Location: Dubuque, Iowa, USA
|
|
|
|
Quote: |
Can anyone confirm if this WHEN clause will work? |
Of course it will -- it may not give you the result you want, but it will evaluate and produce a result.
You need to review chapter 6.1.6 of the COBOL Language Reference manual to determine exactly what you want to do. For example, as you have it coded, if POOL-CD OF DCLTCMPRDCR-ERN-DTL = 'FYGB' is true, none of the following conditions will be checked -- which is due to the way COBOL evaluates conditions as described in chapter 6.1.6. When evaluating OR conditions, either side being true forces the entire condition to be true and evaluation ends at that point. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hi Robert - welcome "back"
d |
|
Back to top |
|
|
Kamlesh Kamal
New User
Joined: 16 May 2008 Posts: 36 Location: Kolkata,India
|
|
|
|
Hi,
Got your point..Now I have divided my logic in two separate parts.
Code: |
EVALUATE TRUE
WHEN (POOL-CD OF DCLTCMPRDCR-ERN-DTL = 'FYGB' OR
POOL-CD OF DCLTCMPRDCR-ERN-DTL = 'FYNB' OR
POOL-CD OF DCLTCMPRDCR-ERN-DTL = 'RENB' OR
POOL-CD OF DCLTCMPRDCR-ERN-DTL = 'RENN' OR
POOL-CD OF DCLTCMPRDCR-ERN-DTL = 'MAVG' OR
POOL-CD OF DCLTCMPRDCR-ERN-DTL = 'MLGA' OR
POOL-CD OF DCLTCMPRDCR-ERN-DTL = 'MGAN' OR
POOL-CD OF DCLTCMPRDCR-ERN-DTL = 'NPMF')
MOVE ERN-AMT OF DCLTCMPRDCR-ERN-DTL
TO WS-STI-COMM-CALC-AMT1
WS-ERN-AMT-OUTPUT |
AND
Code: |
WHEN (SPEC-PSTN-CD OF DCLTCSEPIPRDCR(1:2)
NOT EQUAL TO '72' AND
(POOL-CD OF DCLTCMPRDCR-ERN-DTL = 'MAVF' OR
POOL-CD OF DCLTCMPRDCR-ERN-DTL = 'MAVR' OR
POOL-CD OF DCLTCMPRDCR-ERN-DTL = 'MGAF' OR
POOL-CD OF DCLTCMPRDCR-ERN-DTL = 'MGAR' OR
POOL-CD OF DCLTCMPRDCR-ERN-DTL = 'MLGF' OR
POOL-CD OF DCLTCMPRDCR-ERN-DTL = 'MLGR' OR
POOL-CD OF DCLTCMPRDCR-ERN-DTL = 'RNBF' OR
POOL-CD OF DCLTCMPRDCR-ERN-DTL = 'RNBR' OR
POOL-CD OF DCLTCMPRDCR-ERN-DTL = 'RNNF' OR
POOL-CD OF DCLTCMPRDCR-ERN-DTL = 'RNNR'))
MOVE ERN-AMT OF DCLTCMPRDCR-ERN-DTL
TO WS-STI-COMM-CALC-AMT1
WS-ERN-AMT-OUTPUT |
Still the checks for the conditions in second WHEN clause is not working..
Do I use IS NOT EQUAL TO instaed of NOT EQUAL TO? |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
Why don't you get rid of that dumb NOT and:
Code: |
EVALUATE TRUE
WHEN THINGAMEBOB(WITH REFERENCE MODIFICATION) = '72'
CONTINUE
WHEN <all the other mess without the NOT>
PERFORM DO-WHAT-YOU-WANT
END-EVALUATE |
|
|
Back to top |
|
|
Kamlesh Kamal
New User
Joined: 16 May 2008 Posts: 36 Location: Kolkata,India
|
|
|
|
That can't be done I guess as I have to check for both the condition NOT EQUAL TO 72 AND the other ORs that I have.. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8697 Location: Dubuque, Iowa, USA
|
|
|
|
Thanks, Dick -- it was a nice vacation (although it rained every port, at least the ship was enjoyable).
Kamlesh, changing NOT EQUAL TO to IS NOT EQUAL TO is not going to change the COBOL results -- the two phrases are considered the same by COBOL. As you now have it coded, if the first two bytes of SPEC-PSTN-CD OF DCLTCSEPIPRDCR are equal to '72' then the condition evaluates to false and the rest of the condition will not be evaluated as per COBOL rules cited above. So have you verified that you have data records with something other than '72' in the first two bytes of SPEC-PSTN-CD OF DCLTCSEPIPRDCR?
The rule of thumb is that COBOL evaluates only as much as it has to; if a partial evaluation of a complex OR condition comes up TRUE, then the expression is going to be TRUE and COBOL stops evaluating at that point; similarly, if a partial evaluation of a complex AND condition comes up FALSE, then the expression is going to be FALSE and COBOL stops evaluating at that point. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
Still the checks for the conditions in second WHEN clause is not working.. |
As i suggested earlier, try a test using only the test for '72' in the second WHEN - forget the others. If the test for 72 alone fails, that is the problem. . . |
|
Back to top |
|
|
Terry Heinze
JCL Moderator
Joined: 14 Jul 2008 Posts: 1249 Location: Richfield, MN, USA
|
|
|
|
In addition to the other suggestions, I would add that your EVALUATE is so wordy that it is difficult for many to understand. One option is to move POOL-CD OF DCLTCMPRDCR-ERN-DTL and SPEC-PSTN-CD OF DCLTCSEPIPRDCR(1:2) to field names and reference them by using condition names (88 levels). |
|
Back to top |
|
|
|