COBOL/400 Language Help


SIZE ERROR/NOT SIZE ERROR

A size error condition can occur in three different ways:

  1. When the absolute value of the result of an arithmetic evaluation, after decimal point alignment, exceeds the largest value that can be contained in the result field
  2. When division by zero occurs
  3. In an exponential expression, when:

If a SIZE ERROR phrase is not present and a size error condition occurs, the value of the affected resultant identifier is unpredictable. Values of other resultant identifiers are not affected, as long as no size error occurred for them.

The size error condition applies only to final results, not to intermediate results.

If the resultant identifier is defined with USAGE IS BINARY, or COMPUTATIONAL-4, the largest value that can be contained in it is the maximum value implied by its associated decimal PICTURE character-string.

When a size error occurs, the subsequent action of the program depends on whether or not the ON SIZE ERROR phrase is specified.

If you do specify the ON SIZE ERROR phrase and a size error condition occurs, the value of the resultant identifier affected by the size error is not altered---that is, the error results are not placed in the receiving identifier. After completion of the execution of the arithmetic operation, the imperative statement in the ON SIZE ERROR phrase is executed, control is transferred to the end of the arithmetic statement, and the NOT ON SIZE ERROR phrase, if specified, is ignored.

If you specify the NOT ON SIZE ERROR phrase and, after execution of an arithmetic operation, a size error condition does not exist, the NOT ON SIZE ERROR phrase is executed.

When you specify both the ON SIZE ERROR and NOT ON SIZE ERROR phrases, and the statement in the phrase that is executed does not contain any explicit transfer of control, then, if necessary, an implicit transfer of control is made after execution of the phrase to the end of the arithmetic statement.

For ADD CORRESPONDING and SUBTRACT CORRESPONDING statements, if an individual arithmetic operation causes a size error condition, the ON SIZE ERROR imperative statement is not executed until all the individual additions or subtractions have been completed.


[ Top of Page | Previous Page | Next Page | Table of Contents ]