Summary -

In this topic, we described about the ADD Statement with detailed example.

The ADD statement sums two or more numeric operands. The result stores into target operand.

Syntax-1: ADD statement -

ADD Syntax

All identifiers or literals that are before the keyword TO are added together and the summed result is stored in identifier-2.

Syntax-2: ADD statement with GIVING phrase -

ADD Statement with GIVING Phrase

All identifiers or literals that are before the keyword GIVING are added together and the summed result is stored in identifier-3.

Syntax-3: ADD statement with CORRESPONDING phrase -

ADD Statement with CORRESPONDING Phrase

Elementary data items within identifier-1, identifier-2 are added and stored in the corresponding elementary items within identifier-2.

identifier-1, identifier-2 -

In syntax-1, must be an elementary numeric item. In syntax-2, must be an elementary numeric item except when following the word GIVING. Each identifier follows the keyword GIVING must be an elementary numeric or numeric-edited item. In syntax-3, must be an alphanumeric group item.

In syntax-1, identifier-2 can specify one or more date fields. identifier-1 must not specify a date field. In syntax-2, either identifier-1 or identifier-2 but not both can specify at most one date field.

If neither identifier-1 nor identifier-2 specifies a date field, identifier-3 can specify one or more date fields without any restriction on the date formats.

In syntax-3, only corresponding elementary items within identifier-2 can be date fields. There is no restriction on the format of these date fields.

literal -

Must be a numeric literal. Floating-point data items and literals can use anywhere that a numeric data item or literal can be specified.

GIVING Phrase -

The identifier that follows the GIVING keyword is set to the calculated result of the arithmetic operation. The identifier can be a numeric-edited item.

END-ADD phrase -

The END-ADD used to end the scope of the ADD statement. END-ADD is not required when ADD statement ended with period.

SIZE ERROR phrase

CORRESPONDING phrase

ROUNDED Phrase