Topic
IC4NOTICE: developerWorks Community will be offline May 29-30, 2015 while we upgrade to the latest version of IBM Connections. For more information, read our upgrade FAQ.
No replies
Dave_Dischiave
Dave_Dischiave
3 Posts
ACCEPTED ANSWER

Pinned topic COBOL 88 Levels in an EVALUATE

‏2013-11-13T16:29:00Z |

I was advised by my good friend and colleague, Jonathan Sayles, to post this question to this group … was wondering if anyone knew the rationale for why 88 levels like the one below passes the RDz syntax check; but fails in the compile. More importantly why can't 88 levels be used in EVALUATE statements, using 88 levels in IF statements aside, this seems to reduce the effectiveness of 88 levels don't you think?
 
                  05  PR-LAST-EVAL-RATING    PIC  X(01).
               88  PR-RATE-A              VALUE 'A'.
               88  PR-RATE-B              VALUE 'B'.
               88  PR-RATE-C              VALUE 'C'.
               88  PR-RATE-D              VALUE 'D'.
               88  PR-RATE-N              VALUE 'N'.
 
      **  This works - Count employee evaluation ratings ************
           EVALUATE PR-LAST-EVAL-RATING
              WHEN 'A'
                 ADD 1 TO EVAL-COUNT-A
              WHEN 'B'
                 ADD 1 TO EVAL-COUNT-B
              WHEN 'C'
                 ADD 1 TO EVAL-COUNT-C
              WHEN 'D'
                 ADD 1 TO EVAL-COUNT-D
              WHEN 'N'
                 ADD 1 TO EVAL-COUNT-N
           END-EVALUATE.
 
      **  This doesn't - Count employee evaluation ratings ************
           EVALUATE PR-LAST-EVAL-RATING
              WHEN PR-RATE-A
                 ADD 1 TO EVAL-COUNT-A
              WHEN PR-RATE-B              
                 ADD 1 TO EVAL-COUNT-B
              WHEN PR-RATE-C              
                 ADD 1 TO EVAL-COUNT-C
              WHEN PR-RATE-D              
                 ADD 1 TO EVAL-COUNT-D
              WHEN PR-RATE-N              
                 ADD 1 TO EVAL-COUNT-N
           END-EVALUATE.
 
The compiler message:
==> IGYPA3009-S The selection object at position 1 in the "WHEN" phrase did not match the type of the corresponding selection subject in the "EVALUATE" statement. The selection object was discarded.

Thanks, Dave D

  • craig-s
    craig-s
    7 Posts
    ACCEPTED ANSWER

    Re: COBOL 88 Levels in an EVALUATE

    ‏2013-11-13T18:27:37Z  in response to Dave_Dischiave

    Change your failing EVALUATE to read EVALUATE TRUE instead of EVALUATE PR-LAST-EVAL-RATING.
     

    • Dave_Dischiave
      Dave_Dischiave
      3 Posts
      ACCEPTED ANSWER

      Re: COBOL 88 Levels in an EVALUATE

      ‏2013-11-13T19:11:53Z  in response to craig-s

      Thanks for your response. Can you elaborate as to how Evaluate True ... i.e. does the WHEN clause now behave as a individual IF statements making the EVALUATE  PR-LAST-EVAL-RATING unnecessary? Dave D

      • craig-s
        craig-s
        7 Posts
        ACCEPTED ANSWER

        Re: COBOL 88 Levels in an EVALUATE

        ‏2013-11-13T19:27:39Z  in response to Dave_Dischiave

        The WHEN clauses behave as documented, i.e. they behave as a series of IF/ELSE statements.  Only the code associated with 1 WHEN clause will execute.

         

        • Dave_Dischiave
          Dave_Dischiave
          3 Posts
          ACCEPTED ANSWER

          Re: COBOL 88 Levels in an EVALUATE

          ‏2013-11-13T19:29:52Z  in response to craig-s

          Thank you Craig. Code was revised accordingly and works as advertised. Dave D

  • wmklein
    wmklein
    79 Posts
    ACCEPTED ANSWER

    Re: COBOL 88 Levels in an EVALUATE

    ‏2013-11-13T23:59:09Z  in response to Dave_Dischiave

    I agree that EVALUATE works "as documented", but just so it is clear, there is one additional bit of information that you need to know related to the original question:

     

    Evaluate True

      When 88-Level-A

          Perform Para1

       When 88-Level-B

         Perform Para2

      When Other

       Perform Para3

      End-Evaluate

     

    acts as if you have a series of 3 nested

     If .. Then ... Else

    structures.

    HOWEVER, If you code

    Evaluate True

      When 88-Level-A

       When 88-Level-B

         Perform Para4

      End-Evaluate

    works as if you have only a single IF statement with a test for

      88-Level-A *OR* 88-level-B

    Using multiple WHEN clauses with no intervening imperative statement is (IMHO) one of the "little known" facts about EVALUATE statements.