Condition Names - Multiple Value Example


Scenario - Declaring a condition name with multiple values using 88 level number.

Code -

----+----1----+----2----+----3----+----4----+----5----+
       IDENTIFICATION DIVISION.
       PROGRAM-ID. LEVEL88M.
       AUTHOR. MTH.

       DATA DIVISION.
       WORKING-STORAGE SECTION.

       01 WS-GENDER         PIC X(01) VALUE "A".
      * Condition name with Multiple values
          88 VALID-GENDER    VALUE "M" "F".

       PROCEDURE DIVISION.

           IF VALID-GENDER 
              DISPLAY "Gender is Valid"
           ELSE 
              DISPLAY "Gender is Invalid"
           END-IF.

           STOP RUN.

Output -

Gender is Invalid

Explaining Example -

In the above example:

  • WS-GENDER is declared as a single-byte alphanumeric variable. It has one condition name.
  • VALID-GENDER is a condition name with multiple values. If VALID-GENDER (i.e., IF WS-GENDER EQUALS "M" OR WS-GENDER EQUALS "F") is satisifed, "Gender is Valid" will be displayed. Otherwise, "Gender is Invalid" will be displayed.