The EVALUATE statement provides a shorthand notation for a series of nested IF statements. It can evaluate multiple conditions. The subsequent action depends on the results of these evaluations.
Format >>-EVALUATE--+-identifier-1-+-----------------------------------> +-literal-1----+ +-expression-1-+ +-TRUE---------+ '-FALSE--------' >--+-----------------------------+------------------------------> | .-------------------------. | | V | | '--- ALSO--+-identifier-2-+-+-' +-literal-2----+ +-expression-2-+ +-TRUE---------+ '-FALSE--------' .----------------------------------------------------------------------------. | .------------------------------------------------. | V V | | >------WHEN--| phrase 1 |--+------------------------+-+--imperative-statement-1-+--> | .--------------------. | | V | | '---ALSO--| phrase 2 |-+-' >--+------------------------------------+--+--------------+---->< '-WHEN OTHER--imperative-statement-2-' '-END-EVALUATE-' phrase 1 |--+-ANY--------------------------------------------------------------------------------+--| +-condition-1------------------------------------------------------------------------+ +-TRUE-------------------------------------------------------------------------------+ +-FALSE------------------------------------------------------------------------------+ '-+-----+--+-identifier-3------------+--+------------------------------------------+-' '-NOT-' +-literal-3---------------+ '-+-THROUGH-+--+-identifier-4------------+-' '-arithmetic-expression-1-' '-THRU----' +-literal-4---------------+ '-arithmetic-expression-2-' phrase 2 |--+-ANY--------------------------------------------------------------------------------+--| +-condition-2------------------------------------------------------------------------+ +-TRUE-------------------------------------------------------------------------------+ +-FALSE------------------------------------------------------------------------------+ '-+-----+--+-identifier-5------------+--+------------------------------------------+-' '-NOT-' +-literal-5---------------+ '-+-THROUGH-+--+-identifier-6------------+-' '-arithmetic-expression-3-' '-THRU----' +-literal-6---------------+ '-arithmetic-expression-4-'
Two operands connected by a THRU phrase must be of the same class. The two operands thus connected constitute a single selection object.
The number of selection objects within each set of selection objects must be equal to the number of selection subjects.
Each selection object within a set of selection objects must correspond to the selection subject having the same ordinal position within the set of selection subjects, according to the following rules:
This explicit scope terminator serves to delimit the scope of the EVALUATE statement. END-EVALUATE permits a conditional EVALUATE statement to be nested in another conditional statement.
For more information, see Delimited scope statements.
The execution of the EVALUATE statement operates as if each selection subject and selection object were evaluated and assigned a numeric, alphanumeric, DBCS, or national character value; a range of numeric, alphanumeric, DBCS, or national character values; or a truth value. These values are determined as follows:
The execution of the EVALUATE statement then proceeds as if the values assigned to the selection subjects and selection objects were compared to determine whether any WHEN phrase satisfies the set of selection subjects. This comparison proceeds as follows:
After the comparison operation is completed, execution of the EVALUATE statement proceeds as follows: