The Purpose of ‘When Other’ in COBOL EVALUATE

The Evaluate statement reduces code effort of writing multiple-if statements. Here, you’ll find the purpose of ‘WHEN OTHER’ in the EVALUATE statement.

Evaluate Syntax

The syntax for evaluate is:

EVALUATE TRUE
    WHEN  CONDITION
          PERFORM  PARA1
    WHEN OTHER
         continue
END-EVALUATE.

When Other in Evaluate..

Why “when other ” you need to write in evaluate?

the reasons are simple:

  • This avoids ambiguity to the compiler.
  • If the conditions are not matched, it helps what action it has to take. 
  • During Numeric or character validations, you may get data, which is not expected. So you need a piece of code in WHEN OTHER to handle these.

Related Posts

References

Author: Srini

Experienced software developer. Skills in Development, Coding, Testing and Debugging. Good Data analytic skills (Data Warehousing and BI). Also skills in Mainframe.