Condition-name condition in COBOL

Condition-name Condition

  • Condition name includes a set of values specified by the user.
  • It is a user defined function and behaves like boolean variables.
  • Level number 88 defines this function. It does not have a PIC clause.
Syntax:
88 [condition-Name] VALUE [IS, ARE] [LITERAL] [THRU LITERAL]

Example : Program to demonstrate Condition-name

IDENTIFICATION DIVISION.
PROGRAM-ID. CNC.

DATA DIVISION.
   WORKING-STORAGE SECTION.
   01 SAL-1 PIC 9(5).

   88 GRADE-A VALUES ARE 30000 THRU 50000.
   88 GRADE-B VALUES ARE 10000 THRU 29999.

PROCEDURE DIVISION.
   A000-FIRST-PARA.
   MOVE 27900 TO SAL-1.
    
   IF GRADE-A
      DISPLAY 'GRADE-A Employee with ' SAL-1 ' salary'.
      
   IF GRADE-B
      DISPLAY 'GRADE-B Employee with ' SAL-1 ' salary'
      
STOP RUN.


Output:
GRADE-B Employee with 27900 salary