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.

For more information about conditional expressions, see Conditional expressions.

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

Arithmetic

  • ADD ... ON SIZE ERROR
  • ADD ... NOT ON SIZE ERROR
  • 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 movement

  • JSON GENERATE ... ON EXCEPTION
  • JSON GENERATE ... NOT ON EXCEPTION
  • JSON PARSE ... ON EXCEPTION
  • JSON PARSE ... NOT ON EXCEPTION
  • STRING ... ON OVERFLOW
  • STRING ... NOT ON OVERFLOW
  • UNSTRING ... ON OVERFLOW
  • UNSTRING ... NOT ON OVERFLOW
  • XML GENERATE ... ON EXCEPTION
  • XML GENERATE ... NOT ON EXCEPTION
  • XML PARSE ... ON EXCEPTION
  • XML PARSE ... NOT ON EXCEPTION

Decision

  • IF
  • EVALUATE

Input-output

  • DELETE ... INVALID KEY
  • DELETE ... NOT INVALID KEY
  • READ ... AT END
  • READ ... NOT AT END
  • READ ... INVALID KEY
  • READ ... NOT INVALID KEY
  • REWRITE ... INVALID KEY
  • REWRITE ... NOT INVALID KEY
  • START ... INVALID KEY
  • START ... NOT INVALID KEY
  • WRITE ... AT END-OF-PAGE
  • WRITE ... NOT AT END-OF-PAGE
  • WRITE ... INVALID KEY
  • WRITE ... NOT INVALID KEY

Ordering

  • RETURN ... AT END
  • RETURN ... NOT AT END

Program or method linkage

  • CALL ... ON OVERFLOW
  • CALL ... ON EXCEPTION
  • CALL ... NOT ON EXCEPTION
  • INVOKE ... ON EXCEPTION
  • INVOKE ... NOT ON EXCEPTION

Table-handling

  • SEARCH