Monday, 28 July 2014

COBOL LEVEL 88 Condition | 88 LEVEL in COBOL | 88 level in COBOL Example.

COBOL LEVEL 88 Condition
88 LEVEL in COBOL 

In today's tutorial, I will be discussing 88 LEVEL in COBOL. These are basically used to specify the condition in the COBOL level 88 conditions program. So, let's start with the COBOL LEVEL 88 Condition tutorial.

What is 88 LEVEL in COBOL?


A condition name is a user-defined word that gives a name to a specific value that an identifier can assume. It is essentially a Boolean variable and is always associated with data names called condition variables. 88 LEVEL in COBOL can be used with IF, Evaluate statement or perform until statement. 

88 LEVEL in COBOL FORMAT.   

88 condition-name VALUE IS {literal-1[{THROUGH, THRU} literal-2].

It is coded with level number 88 and has only a VALUE clause associated with it. Since it is not the name of an identifier, it will not possess the PIC clause.

To define a condition name, you use an 88 level in the Data Division as shown below figure. Once defined, the condition name can be used as the condition in an If, Perform Until, or Evaluate statement. For instance, EOF-FILE is the name for the condition. 

88 level declaration in COBOL.

01 FLE-STATUS            PIC X(01) VALUE 'N'. 
   88 EOF-FILE                     VALUE 'Y'.
   88 NOT-EOF-FILE                 VALUE 'N'.

Condition names are frequently used with switches and flags. As you should already know, a switch is a one-character field that has either a value of N for No or Y for Yes.

Two or more values can be coded in the Value clause for a condition. Also, the word THRU can be coded to express a series of values. 

In general, a switch is a field with just two possible settings: Yes and No (or Off and On). In contrast, a flag is a field that can have two or more possible settings.

88 level in COBOL Example. 


Example 1 : 88 level in COBOL used with Perform until.


COBOL Level 88 condition
88 level in COBOL Example

Example 2 :  COBOL LEVEL 88 condition in PERFORM Until. 

COBOL LEVEL 88 CONDITION
PERFORM UNTIL with level 88
Example 3: COBOL LEVEL 88 CONDITION in EVALUATE STATEMENT.

WORKING-STORAGE SECTION.

01 MARTIAL-STATUS            PIC X(01) VALUE ' '.
   88 SINGLE                           VALUE 'S'.  
   88 MARRIED                          VALUE 'M'.
   88 DIVORCED                         VALUE 'D'.
   88 WIDOW                            VALUE 'W'.  

PROCEDURE DIVISION.
A010-MAIN-LOGIC.
     EVALUATE TRUE
         WHEN SINGLE
              DISPLAY 'SINGLE' 
         WHEN MARRIED
              DISPLAY 'MARRIED'
         WHEN DIVORCED
              DISPLAY 'DIVORCED' 
         WHEN WIDOW
              DISPLAY 'WIDOW'
         WHEN OTHER
              DISPLAY 'IN CORRECT VALUE'  
      END-EVALUATE.    

Coding recommendations for 88 level conditions in COBOL.

  • Use condition names for all switches and flags because they make a program easier to understand.
  • Use the Set to True statement shown in the above two examples to turn on switches and flag conditions.


What's Next in COBOL? 


Created with Artisteer

2 comments:

  1. In the third example ,how are u checking the marital status,when u havent used the variable at all

    ReplyDelete
  2. Through this evaluate i want the other conditions to be true for example single must be true
    how to do so

    ReplyDelete