Admin Production rocket
Current Publication

ADD Statement

NetExpress Bookshelf Help V5.1 WrapPack 1
Rocket® Net Express™ (formerly a product of Micro Focus or formerly a product of Open Text) documentation, created before Rocket Software acquired certain products from OpenText, may include outdated references to "Micro Focus" or "OpenText", both of which are trademarks of OpenText or its affiliates. Rocket Software is not affiliated with Micro Focus or OpenText and has since rebranded these products as Rocket® products. You may also encounter outdated links in this documentation. If you do, please contact Rocket Support (support@rocketsoftware.com) for assistance.

The ADD Statement

The ADD statement causes two or more numeric operands to be summed and the result to be stored.

General Formats
Format 1
Format 2
Format 3
Syntax Rules
  1. All Formats
  2. In Formats 1 and 2, each identifier must refer to an elementary numeric item, except that in Format 2 each identifier following the word GIVING must refer to either an elementary numeric item or an elementary numeric edited item. In Format 3, each identifier must refer to a group item.
  3. Each literal must be a numeric literal.
  4. The composite of operands is determined as follows (see the topic Arithmetic Statements in the chapter Procedure Division):
    1. In Format 1, by using all of the operands in a given statement.
    2. In Format 2, by using all of the operands in a given statement excluding the data items that follow the word GIVING.
    3. In Format 3, separately for each corresponding pair of data items.
  5. In Format 3, CORR is an abbreviation for CORRESPONDING.
  6. OSVSVSC2MFFloating-point literals and floating-point data items can be used anywhere a numeric data item or literal can be specified.
General Rules
  1. All Formats
  2. See the topics The ROUNDED Phrase, The ON SIZE ERROR Phrase, The CORRESPONDING Phrase, Arithmetic Statements, Overlapping Operands and Multiple Results in Arithmetic Statements in the chapter Procedure Division; the section Explicit and Implicit Scope Terminators in the chapter Concepts of the COBOL Language, and the section Delimited Scope Statements in the chapter Language Fundamentals.
  3. If Format 1 is used, the values of the operands preceding the word TO are added together, then this sum is added to the current value of identifier-2 storing the result immediately into identifier-2, and repeating this process respectively for each successive operand following the word TO in left-to-right order.
  4. If Format 2 is used, the value of the operands preceding the word GIVING are added together, then the sum is stored as the new value of each data item referenced by identifier-3, the resultant identifier.
  5. If Format 3 is used, data items in identifier-1 are added to and stored in corresponding data items in identifier-2.
  6. MFYour COBOL system ensures that enough places are carried so as not to lose any significant digits during execution.