(Area 3)
The ADD command algebraically increments a predefined numeric field by a specified numeric constant or the contents of another predefined numeric field.
The format of the ADD command is as follows:
►►─┬──────────┬─ ADD ─┬─ fieldname1 ───────┬─┬───────┬─ fieldname2 ───────────► └─ label: ─┘ └─ numeric constant ─┘ ├─ AND ─┤ └─ TO ──┘ ►─┬───────────────────────────┬─┬─────────┬──────────────────────────────────►◄ └─┬──────────┬─ fieldname3 ─┘ └─ ROUND ─┘ └─ GIVING ─┘
Specifies an identifying label that allows a GOTO branch to be made to this statement.
Specifies the name given a predefined numeric field whose value is to be added to the numeric value in fieldname2. Predefine the field name as zoned decimal, packed decimal, binary, or unsigned binary.
Specifies the name given a predefined numeric field whose value is to be used as the base for the addition of two variables. Predefine the field name as zoned decimal, packed decimal, binary, or unsigned binary.
Specifies an absolute numeric constant to add to the contents of fieldname2. It can be any valid numeric literal.
Optionally specifies a predefined numeric field in which the sum is placed. Predefine the field name as either zoned decimal or packed decimal.
Optionally defines whether the result will be rounded before being placed into the result field. For rounding to occur, the computed value must have more decimal places than the result field. The default is not to round.
Example
Predefined field name: FIELD1 FIELD2 FIELD3 INDEX
Numeric precision: 3.2 1.4 3.4 2.0
Initial value of field: (123.45) (5.4321) (zero) (3)
ADD 1 TO FIELD1 124.45 nc nc nc
ADD FIELD2 TO FIELD3 nc nc 5.4321 nc
ADD FIELD1 TO FIELD2
GIVING FIELD3 nc nc 128.8821 nc
ADD -123 TO FIELD1 0.45 nc nc nc
ADD 10 TO FIELD2
GIVING FIELD3 nc nc 15.4321 nc
ADD FIELD1 TO FIELD1 246.90 nc nc nc
ADD INDEX TO FIELD3 nc nc 3.0000 nc
ADD FIELD1 TO INDEX FIELD2 nc 6.4500 nc nc
ADD INDEX TO INDEX nc nc nc 6
ADD -1 TO INDEX nc nc nc 2
ADD +66 TO INDEX nc nc nc 69
ADD .333 TO FIELD2
GIVING FIELD1 ROUND 5.77 nc nc nc
Note the following:
|
Copyright © 2014 CA.
All rights reserved.
|
|