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
 

 

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: 7936
Location: Bellevue, IA

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: 6966
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: 7936
Location: Bellevue, IA

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: 1239
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 Converting multiple VB files to FB fi... Viswanath Reddy JCL & VSAM 6 Mon Aug 08, 2016 11:49 pm
No new posts Execute multiple DB2 Load commands in... faizm DB2 4 Wed Aug 03, 2016 12:53 pm
This topic is locked: you cannot edit posts or make replies. JCL MULTIPLE STEP EXECUTION QUERY Susanta JCL & VSAM 18 Sat Jul 30, 2016 1:17 pm
No new posts Need help on SQL Dynamic WHERE Clause subratarec DB2 12 Sat Jul 16, 2016 3:11 pm
No new posts Multiple parameters Csongor All Other Mainframe Topics 16 Thu Jun 09, 2016 7:54 pm


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