Previous Topic: Reporting Facility CommandsNext Topic: CALL Command


ADD Command

(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 ─┘
label:

Specifies an identifying label that allows a GOTO branch to be made to this statement.

fieldname1

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.

fieldname2

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.

numeric constant

Specifies an absolute numeric constant to add to the contents of fieldname2. It can be any valid numeric literal.

fieldname3

Optionally specifies a predefined numeric field in which the sum is placed. Predefine the field name as either zoned decimal or packed decimal.

ROUND

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: