COBOL Manual for TNS/E Programs (H06.08+, J06.03+)

match-imp-stmt
is an imperative statement to be executed when the values of the objects in the associated
object-list match the values of the corresponding subjects in the subject-list.
no-match-imp-stmt
is an imperative statement to be executed when no match-imp-stmt applies. After
no-match-imp-stmt executes, control passes to the end of the EVALUATE statement.
END-EVALUATE
ends the scope of the EVALUATE statement and makes it a delimited-scope statement. If you
omit END-EVALUATE, the EVALUATE statement is a conditional statement and ends at the next
period separator.
Usage Considerations:
EVALUATE in Comparison to “Case” Statement
The EVALUATE statement is a generalization of what some languages call the case statement,
a statement that enables you to execute one of several groups of statements depending on
the value of a single data item.
Example 88 EVALUATE Statement as “Case” Statement
EVALUATE TRAN-CODE
WHEN 1 PERFORM TRAN-1
WHEN 2 PERFORM TRAN-2
WHEN 3 PERFORM TRAN-3
WHEN OTHER PERFORM TRAN-BAD
END-EVALUATE
Example 89 EVALUATE Statement With Both Ranges and Discrete Values
EVALUATE SALARY OF PAYROLL-REC
WHEN 15000 THRU 29999.99 PERFORM LOW-BRACKET
WHEN 30000 THRU 49999.99 PERFORM MIDL-BRACKET
WHEN 50000 THRU 99999999 PERFORM HIGH-BRACKET
WHEN OTHER PERFORM NO-BRACKET
END-EVALUATE
The EVALUATE statement extends the “case” statement concept by allowing several selection
subjects and matching objects—the equivalent of a decision table. The EVALUATE statement in
Example 90 uses the values of two distinct subjects to make its selection.
Example 90 EVALUATE Statement With Two Distinct Subjects
EVALUATE DEDUCTIONS ALSO SALARY
WHEN 0 ALSO 0 THRU 14999.99 PERFORM XXA
WHEN 0 ALSO 15000 THRU 29999.99 PERFORM YYA
WHEN 0 ALSO 30000 THRU 49999.99 PERFORM ZZA
WHEN 1 THRU 2 ALSO 0 THRU 19999.99 PERFORM XXB
WHEN 1 THRU 2 ALSO 20000 THRU 69999.99 PERFORM YYB
WHEN 1 THRU 2 ALSO 70000 THRU 99999999 PERFORM ZZB
WHEN OTHER PERFORM FURTHER-ANALYSIS
END-EVALUATE
The selection objects (the “0” and “1 THRU 2” of Example 90) are not restricted to being literals
or ranges of literals; they can also be (for example) condition names, identifiers, and arithmetic
expressions.
The WHEN OTHER phrase is commonly used as the mechanism for handling errors, enabling the
program to detect invalid values for subjects and improper specification of objects.
326 Procedure Division Verbs