Adds a value to an ABL data element. Provides a shorter syntax for applying concatenation, numeric addition, and date-based addition.

Syntax

field += expression [ NO-ERROR ]

field += expression is equivalent to field = field + (expression).

Note: Spaces are required around the assignment operator. You cannot write field+=expression.
Note: This syntax can also be used in the ASSIGN, BUFFER-COPY, SET, and UPDATE statements.
field
The name of an ABL data element to which you want to add the value of expression, and that is defined with a data type that is compatible with the data type of expression. Valid data types are INTEGER, INT64, DECIMAL, CHARACTER, LONGCHAR, DATE, DATETIME, and DATETIME-TZ. The data element can include:
  • A database or temp-table field
  • A variable scoped to the current procedure, user-defined function, or method of a class, or an accessible class-based variable data member, including a subscripted array variable
  • A parameter defined for the current procedure, user-defined function, or method of a class, including a subscripted array parameter
  • A writable class-based or COM property, including a subscripted array property
  • A writable handle attribute or system handle attribute
  • ABL syntax that specifies the CURRENT-VALUE statement, DYNAMIC-CURRENT-VALUE statement, DYNAMIC-PROPERTY statement, ENTRY statement, EXTENT statement, LENGTH statement, PROPATH statement, or SUBSTRING statement
expression
An expression with a data type that is consistent with the data type of field.
NO-ERROR
The NO-ERROR option is used to prevent the statement from raising ERROR and displaying error messages. With the NO-ERROR option, if ERROR is raised, then the ABL element on the left-hand side of the assignment is unchanged.
Note: For more information on the rules related to assignment, see the notes section in the Assignment (=) statement reference entry.

Examples

The following example shows how to do string concatenation using the += assignment operator. Note that the data types (CHAR and LONGCHAR) are compatible.

VAR LONGCHAR str1 = "abc".
VAR CHAR str2 = "def".

str1 += str2.  // abcdef

/* Equivalent statement
str1 = str1 + str2.  */

The following example shows how to do integer addition using the += assignment operator.

VAR INT i1 = 100.
VAR INT i2 = 50.

i1 += i2.  // 150

/* Equivalent statement
i1 = i1 + i2.        */

The following example uses the += assignment operator on variables with mixed numeric data types.

VAR INT i1 = 10.
VAR INT64 i2 = 1000.
VAR DECIMAL d1 = 20.5.

i1 += i2 + d1.  // 1031

/* Equivalent statement
i1 = i1 + (i2 + d1). */

The following example uses the += assignment operator to add 7 days to a DATE variable.

VAR DATE date1 = 06/01/2020.

date1 += 7.  // 06/08/2020

/* Equivalent statement
date1 = date1 + 7.   */

The following example uses the += assignment operator to update a database field.

VAR INT extraDiscount = 300.

FIND FIRST customer.
customer.discount += extraDiscount.

/* Equivalent statement
customer.discount = customer.discount + extraDiscount. */

The following example uses the += assignment operator to update a class property:

VAR ClassA myObj.
VAR INT myValue = 10.

myObj = NEW ClassA().
myObj:MyIntProp  = 250.
myObj:MyIntProp += myValue.  // 260

/* Equivalent statement
myObj:MyIntProp = myObj:MyIntProp + myValue. */
The following example code uses the += assignment operator, within an ASSIGN statement, to update the CreditLimit field and the myCtr variable.
VAR INT myCtr = 0.

FOR EACH Customer WHERE NAME BEGINS "K":
    ASSIGN 
        CreditLimit += 1000 
        myCtr += 1. 
END.

/* Equivalent statement
ASSIGN CreditLimit = CreditLimit + 1000 myCtr = myCtr + 1. */
The following example code uses the += assignment operator to add to the PROPATH.
PROPATH += ",/myNewAppDir1,/myNewAppDir2".

See also

Assignment (=) statement, ASSIGN statement, + Addition operator, + Concatenation operator, + Date addition operator, + Datetime addition operator