Skip to content

PROCEDURE DIVISION STATEMENTS

PROCEDURE DIVISION statements must begin with a reserved word called a verb.

General Format:

       { procedure-sect SECTION [segment-no] . 
       [ procedure-para. 
              [ procedure-statement ] ... ] ... } ...

General Rules:

The General Rules for the different Procedure Division statements are described below.

Common General Rules are General Rules that apply to more than one Statement.

Common General Rules

ROUNDED

  1. The effect of the ROUNDED clause is to cause the least significant digit to be increased by 1 if the next least significant digit of the intermediate result is greater than or equal to 5.
  2. When there is no ROUNDED clause specified, the next least significant digit, and all subsequent digits in the intermediate result are truncated.

ON SIZE ERROR

  1. The SIZE ERROR exception is triggered if the ON SIZE ERROR clause is present and if the receiving field is not large enough to acco mmodate the result of an arithmetic function.
  2. In the absence of an ON SIZE ERROR clause, if the receiving field is not large enough to accommodate the result of the ADD function, the high order digits that cannot be accommodated are truncated. For example, if you ADD 6 TO 6, and attempt to store the result in a PIC 9 field, the result will be 2.
  3. The ON SIZE ERROR clause provides the programmer with a way to respond to the SIZE ERROR exception by performing a statement, or a series of statements.
  4. The NOT ON SIZE ERROR condition exists if the NOT ON SIZE ERROR clause is present, and a SIZE ERROR exception is not triggered.
  5. The NOT ON SIZE ERROR clause provides the programmer with a way to respond to the NOT ON SIZE ERROR condition by performing a statement, or a series of statements.

ARITHMETIC ORDER OF EVALUATION

  1. Arithmetic expressions within parentheses are evaluated first.
  2. Within nested sets of parentheses, the innermost set of parentheses is evaluated first. Sets of parentheses inside a nested set of parentheses then are evaluated from innermost to outermost.
  3. Inside parentheses, or following the complete evaluation of all expressions within parentheses, or in expressions where there are no parentheses, arithmetic expressions evaluate arithmetic operators in the following order:
    • Unary. The Sign (+ or -) is applied The minus “ “--“ sign has the effect of causing the expression to be multiplied by 1. The plus “+” sign has the effect of causing the expression to be multiplied by +1.
    • Exponents. Exponentiation is applied. The exponentiation “**” sign has the effect of raising the expression to the exponential value expressed after the exponentiation sign.
    • Multiplication and Division. Where there are no parentheses to establish order of execution, an arithmetic expression containing successive multiplication and division operators is evaluated from left to right.
    • Addition and Subtraction . Where there are no parentheses to establish order of execution, an arithmetic expression containing successive addition and subtraction operators is evaluated from left to right.
  4. The number of left parentheses in an arithmetic expression must equal the number of right parentheses in the arithmetic expression.

ARITHMETIC CALCULATIONS

  1. Certain common general rules apply to each of the arithmetic statements ADD, COMPUTE, DIVIDE, MULTIPLY, and SUBTRACT.
  2. The maximum size of a numeric field is 36 digits.
  3. The compiler constructs data items as needed to hold intermediate results in an arithmetic operation.
  4. The final operation in an arithmetic expression transfers the final value to the receiving field. If the receiving field is too small to accommodate the result, and if there is no ON SIZE ERROR clause, then truncation occurs on the high-order digits before the decimal point, and on the low-order digits after the decimal point.

Rules for identifying CORRESPONDING data elements

  1. A data element cannot be considered a CORRESPONDING data element if:
    • The data element name is not matched.
    • The data element is described as FILLER.
    • The data element is described as a REDEFINES of another data item.
    • The data element is described as a RENAMES of another data item.
    • The data element has an OCCURS clause.
  2. If none of the above apply, then a data element in a target group is considered a CORRESPONDING data element if:
    • It has the same name as a data element in the src group item, and, if it is has one or more parent data items that are not the src-group-item, then all of the parent data items in the src-group-item and target-group-item also have the same names.
Back to top