Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Multiple checks in a WHEN clause

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
Kamlesh Kamal

New User


Joined: 16 May 2008
Posts: 36
Location: Kolkata,India

PostPosted: Mon Sep 28, 2009 8:56 pm    Post subject: Multiple checks in a WHEN clause
Reply with quote

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
View user's profile Send private message

dick scherrer

Site Director


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

PostPosted: Mon Sep 28, 2009 9:12 pm    Post subject:
Reply with quote

Hello,

What happens if the code only checks for NOT EQUAL TO '72'? Does this evaluate true?
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8165
Location: East Dubuque, Illinois, USA

PostPosted: Mon Sep 28, 2009 9:23 pm    Post subject:
Reply with quote

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
View user's profile Send private message
dick scherrer

Site Director


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

PostPosted: Mon Sep 28, 2009 9:27 pm    Post subject: Reply to: Multiple checks in a WHEN clause
Reply with quote

Hi Robert - welcome "back" icon_smile.gif

d
Back to top
View user's profile Send private message
Kamlesh Kamal

New User


Joined: 16 May 2008
Posts: 36
Location: Kolkata,India

PostPosted: Mon Sep 28, 2009 9:32 pm    Post subject: Reply to: Multiple checks in a WHEN clause
Reply with quote

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
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Mon Sep 28, 2009 9:43 pm    Post subject: Reply to: Multiple checks in a WHEN clause
Reply with quote

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
View user's profile Send private message
Kamlesh Kamal

New User


Joined: 16 May 2008
Posts: 36
Location: Kolkata,India

PostPosted: Mon Sep 28, 2009 10:20 pm    Post subject: Reply to: Multiple checks in a WHEN clause
Reply with quote

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
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8165
Location: East Dubuque, Illinois, USA

PostPosted: Mon Sep 28, 2009 11:05 pm    Post subject:
Reply with quote

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
View user's profile Send private message
dick scherrer

Site Director


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

PostPosted: Tue Sep 29, 2009 12:29 am    Post subject:
Reply with quote

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
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1249
Location: Richfield, MN, USA

PostPosted: Tue Sep 29, 2009 1:09 am    Post subject:
Reply with quote

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
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 ejck thru rexx to multiple jobs insid... Susanta All Other Mainframe Topics 5 Tue Sep 19, 2017 1:39 pm
No new posts PLI - printing from multiple programs Pedro PL/I & Assembler 8 Fri Sep 08, 2017 6:36 am
No new posts Repeat part of record multiple times Learncoholic DFSORT/ICETOOL 4 Tue Aug 29, 2017 11:33 am
No new posts Match two files using multiple keys a... santoshks1987 SYNCSORT 11 Fri Aug 18, 2017 10:50 am
No new posts Multiple VSAM files single output fil... Mohan Kothakota DFSORT/ICETOOL 11 Wed Aug 09, 2017 7:57 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us