Conditional Statements

A conditional statement specifies that the truth value of a condition is to be determined, and that the subsequent action of the object program is dependent on this truth value. (See Conditional Expressions.)

Figure 1 lists COBOL statements that are conditional, or that become conditional when a condition is included (for example: ON SIZE ERROR, or ON OVERFLOW) and the statement is not terminated by its explicit scope terminator.

Figure 1. Conditional Statements
Arithmetic                      Ordering
ADD...ON SIZE ERROR             RETURN...AT END
ADD...NOT ON SIZE ERROR         RETURN...NOT AT END
COMPUTE...ON SIZE ERROR
COMPUTE...NOT ON SIZE ERROR
DIVIDE...ON SIZE ERROR
DIVIDE...NOT ON SIZE ERROR
MULTIPLY...ON SIZE ERROR
MULTIPLY...NOT ON SIZE ERROR
SUBTRACT...ON SIZE ERROR
SUBTRACT...NOT ON SIZE ERROR
Data Manipulation               Subprogram Linkage
STRING...ON OVERFLOW            CALL...ON OVERFLOW
STRING...NOT ON OVERFLOW        CALL...ON EXCEPTION
UNSTRING...ON OVERFLOW          CALL...NOT ON EXCEPTION
UNSTRING...NOT ON OVERFLOW
IBM Extension XML GENERATE...ON EXCEPTION
XML GENERATE...NOT ON EXCEPTION
XML PARSE...ON EXCEPTION
XML PARSE...NOT ON EXCEPTION End of IBM Extension
Decision                        Table Handling
IF                              SEARCH...WHEN
EVALUATE
Input/Output
ACCEPT...ON EXCEPTION                  READ...NO DATA
ACCEPT...NOT ON EXCEPTION              REWRITE...INVALID KEY
DELETE...INVALID KEY                   REWRITE...NOT INVALID KEY
DELETE...NOT INVALID KEY               START...INVALID KEY
DISPLAY...ON EXCEPTION                 START...NOT INVALID KEY
DISPLAY...NOT ON EXCEPTION             WRITE...AT END~OF~PAGE
READ...AT END                          WRITE...NOT AT END~OF~PAGE
READ...NOT AT END                      WRITE...INVALID KEY
READ...INVALID KEY                     WRITE...NOT INVALID KEY
READ...NOT INVALID KEY