Rational Developer for System z
Enterprise COBOL for z/OS, Version 4.1, Programming Guide


Specifying the order of evaluation

Because of the restrictions on date fields in arithmetic expressions, you might find that programs that previously compiled successfully now produce diagnostic messages when some of the data items are changed to date fields.

01 Dates-Record.
    03 Start-Year-1 Pic 99 Date Format yy.
    03 End-Year-1   Pic 99 Date Format yy.
    03 Start-Year-2 Pic 99 Date Format yy.
    03 End-Year-2   Pic 99 Date Format yy.
. . .
    Compute End-Year-2 = Start-Year-2 + End-Year-1 - Start-Year-1.

In the example above, the first arithmetic expression evaluated is:

Start-Year-2 + End-Year-1

However, the addition of two date fields is not permitted. To resolve these date fields, you should use parentheses to isolate the parts of the arithmetic expression that are allowed. For example:

Compute End-Year-2 = Start-Year-2 + (End-Year-1 - Start-Year-1).

In this case, the first arithmetic expression evaluated is:

End-Year-1 - Start-Year-1

The subtraction of one date field from another is permitted and gives a nondate result. This nondate result is then added to the date field End-Year-1, giving a date field result that is stored in End-Year-2.


Terms of use | Feedback

This information center is powered by Eclipse technology. (http://www.eclipse.org)