Example: flags
The following examples show how you can use several level-88
items together with an EVALUATE
statement to determine
which of several conditions in a program is true.
Consider for example a program that updates a main file. The updates are read from a transaction file. The records in the file contain a field that indicates which of the three functions is to be performed: add, change, or delete. In the record description of the input file, code a field for the function code using level-88 items:
01 Transaction-Input Record
05 Transaction-Type Pic X.
88 Add-Transaction Value "A".
88 Change-Transaction Value "C".
88 Delete-Transaction Value "D".
The code in the PROCEDURE DIVISION
for
testing these condition-names to determine which function is to be
performed might look like this:
Evaluate True
When Add-Transaction
Perform Add-Main-Record-Paragraph
When Change-Transaction
Perform Update-Existing-Record-Paragraph
When Delete-Transaction
Perform Delete-Main-Record-Paragraph
End-Evaluate