ABAP Keyword Documentation → ABAP - Reference → Processing Internal Data → Assignments
= - Assignment Operator
Other versions:
7.31 | 7.40 | 7.54
Syntax
lhs = rhs.
Effect
If the character =
is specified in a statement between a left side
lhs (or "left hand side") and a right side rhs
(or "right hand side"), it functions like an
assignment operator that assigns the value of the right side to the left side, possibly using a
conversion.
The right side rhs
, the source of the assignment, is a
general expression position and can be specified as follows:
- As a single data object
- As a return value or result of functional methods, predefined functions, or constructor expressions or table expressions
- As a result of calculation expressions
The left side lhs
, the target of the assignment, is a both a
declaration position and a
result position and can be specified as follows:
- As any data object that can be specified in a
writer position. The data type of the data object must either be
compatible with the assigned value or must be convertible to the data type of
lhs
in accordance with one of the conversion rules. If the assigned value does not match the data type oflhs
, the exceptions described in the conversion rules may be raised.
- As an inline declaration
DATA(var)
. The data type of the declared variable is determined by the right side and is described as one of therhs
options. Any variables used on the right side cannot be declared on the left side. An identically named data object from a more global context can be used on the right side and is not hidden by the local declaration until after the statement.
- As a writable expression representing an operand to which the right side can be assigned.
If an exception is raised on the right side, the statement is not executed and the value of the target field remains unchanged.
Notes
- If
lhs
is not a data object, it can be prefixed with the obsolete keywordCOMPUTE
. This keyword is ignored, however, and should no longer be used.
- Another obsolete variant of the assignment is the statement
MOVE rhs TO lhs. Here, the left side is on the right side and does not cover all options of the assignment operator
=
.
Programming Guideline
Assignments with the assignment operators =
and ?=
only