Skip to content

ABAP Keyword Documentation →  ABAP - Reference →  Processing Internal Data →  Assignments →  = - Assignment Operator →  = - Assign Calculation Expressions 

=, Arithmetic Expression

Other versions: 7.31 | 7.40 | 7.54

Syntax


result = arith_exp.

Effect

If an arithmetic expression arith_exp is specified on the right side of the assignment operator =, its calculation type is calculated and assigned to the left side result.

The following can be specified for result:

  • A variable compatible with the numeric result of the arithmetic expression or to whose type the result can be converted.
  • An inline declaration DATA(var). The data type of the declared variable var is the statically identifiable calculation type, where generically typed field symbols and formal parameters are respected using a standard type described there.

If an existing variable is specified for result, its data type is respected when determining the calculation type. If the calculation type is not the data type of result, the result is converted to the data type of the result field before the assignment is made.


Notes

  • The fact that the result field is respected when the calculation type is determined is a special property of ABAP that should always be kept in mind.
  • The calculation type that is dependent on the data type of the result field is a major different from an assignment of data objects; if data objects are incompatible, the source field is always converted to the data type of the target field. When arithmetic expressions are assigned, their operands can also be converted to the data type of the result field before the calculation.

Example

The first assignment is an assignment of an arithmetic expression, because of its sign. The calculation type is determined as i and result is given the value "731036", the number of days since 01.01.0001. The second assignment, on the other hand, has the same meaning as an assignment of data objects and produces the value "20020704" in result.

DATA: result TYPE string, 
      date   TYPE d VALUE '20020704'. 

result = + date. 
result =   date.