Syntax
ADD expression variable [ GIVING variable ] [ ROUNDED ] [ GS status ]
Parameters
Add can be abbreviated as AD.
expression variable
The numeric expression and qualifier to add together. The qualifier also receives the result if the Giving command option is not specified.
GIVING variable
GIVING can be abbreviated as GIV. Directs the result to the specified qualifier.
ROUNDED
ROUNDED can be abbreviated as ROU. Rounds the result to the number of decimal places defined by the destination of the result.
GS status
Indicates arithmetic overflow using the specified variable. On MCP-based systems, if GS isn’t used and an overflow occurs, the system or report could abnormally terminate.
Description
The Add logic command adds the value of a numeric expression to the value of a number-primitive variable, and stores the result in that variable, or optionally adds the result of the first expression with the result of the second expression and stores the result in a specified result variable. The destination qualifier specifies the number of decimal places in the result. Data truncation will occur if the numeric expression is defined with more decimal places than the qualifier.
The behavior of the Add logic command can be replicated using the '+' arithmetic operator. Use of arithmetic operators, where possible, rather than arithmetic logic commands, is the LDL+ preferred format.
Failure behavior
The Glb.Status segment attribute is not set. Use the GS command option to test for arithmetic overflow.
Examples
Add 1 Counter Add Amount Subtotal Rounded Add Amount Subtotal Giving Total Add (Amount * 0.10) (Subtotal + 15) Giving Total Add Amount Cust.Balance GS SD_Stat