ABAP Keyword Documentation → ABAP - Reference → Assignments → Value Assignments
MOVE
Other versions: 7.31 | 7.40 | 7.54
Syntax
MOVE {source {TO|?TO} destination}
| {EXACT source TO destination}.
destination {=|?=} source.
Effect
Both of these statements assign the content of the source
operand to the destination
data object, whereby any necessary conversions are carried out in accordance with the
conversion rules.
-
Variants with the addition
TO
or the assignment operator=
must be used for all assignments between operands that are not reference variables and for assignments between reference variables for which the static type ofsource
is more specific than or the same as the static type ofdestination
(up cast). -
Variants with the addition
?TO
or the assignment operator?=
(casting operator) must be used if thesource
anddestination
are reference variables and the static type ofsource
is more general than the static type ofdestination
(down cast). For assignments between operands that are not reference variables, use of the question mark?
is not permitted. -
The addition
EXACT
, which cannot be used with?TO
and is currently only possible with theMOVE
statement, implements a lossless assignment for which an exception is raised when content is lost or invalid values arise.
destination
can be any data object that can be listed at a
write position. source
is an enhanced
functional operand position in which
functional methods or all
predefined functions that have exactly one unnamed argument can be declared.
The data type of the data object destination
must be either
compatible with the data
type of source
or it must be possible to convert the content of source
into the data type of destination
in accordance with one of the
conversion rules. If the value of source
does not match the data type of destination
, the exceptions described in
the conversion rules may be raised. When the addition
EXACT is specified, the assigned content is checked and an further exceptions are raised
if the assignment causes values to be lost or produces invalid values. After an exception, the content of destination
is determined by the category of the data type.
Notes
-
I is not possible to specify a
calculation expression
expr
for the source field of the statement MOVE. There is noMOVE expr TO result
statement. Conversely, the result = expr statement does not correspond toMOVE
but to aCOMPUTE
statement, and the rules described there apply. -
If
source
and/ordestination
are field symbols, then, as in all ABAP commands, the system works with the content of the data objects to which the field symbols point. The actual pointer content of a field symbol can only be changed using the statementASSIGN
or the additionASSIGNING
when processing internal tables (value semantics). Ifsource
anddestination
are reference variables, the reference contained insource
is assigned todestination
(reference semantics). - Strings and internal tables are addressed internally using references. When assignments are made between strings and between internal tables of the same type (if the line type itself does not contain any table types), for performance reasons, only the internal administrative information is passed. After the assignment, the actual string or the actual table body of the source as well as the target object are addressed (sharing). Sharing is valid until the object is accessed to be changed. At this point, the sharing is canceled and a copy of the content is made. The sharing is displayed in the memory consumption display of the ABAP Debugger and in the Memory Inspector tool. For internal tables of which the line type itself contains internal table types or Boxed Components, no sharing takes place. Sharing can, however, take place for the subtables of a line type.
-
If an internal table with a header line is specified as an operand of an assignment, in nearly all
operand positions, the header line is addressed and not the
table body. To address the table body of a table with a header line,
[]
must be appended to the table name. -
One obsolete form of the statement
MOVE
isMOVE PERCENTAGE
.
Exceptions
Catchable Exceptions
CX_SY_CONVERSION_NO_NUMBER
-
Cause: Operand cannot be interpreted as number when assigned to a numeric data type
Runtime Error:CONVT_NO_NUMBER
CX_SY_CONVERSION_OVERFLOW
-
Cause: Overflow in arithmetic operation (type
p
, with specified length)
Runtime Error:BCD_FIELD_OVERFLOW
-
Cause: Operand too big or (interim) result too big
Runtime Error:CONVT_OVERFLOW
CX_SY_MOVE_CAST_ERROR
-
Cause: Type conflict in down cast
Runtime Error:MOVE_CAST_ERROR
-
Cause: Source variable or target variable is not a reference variable
Runtime Error:MOVE_CAST_REF_ONLY
-
Cause: Dynamic type conflict in assignment of references
Runtime Error:MOVE_CAST_ERROR_DYN
Non-Catchable Exceptions
-
Cause: Source field (type
p
) contains an incorrect BCD format
Runtime Error:BCD_BADDATA
-
Cause: Assignment for deep structures not allowed if they overlap
Runtime Error:MOVE_COMPLEX_OVERLAP
-
Cause: Type conflict in assignment between object references
Runtime Error:MOVE_INTERFACE_NOT_SUPPORTED
,
Runtime Error:MOVE_IREF_NOT_CONVERTIBLE
,
Runtime Error:MOVE_IREF_TO_OREF
,
Runtime Error:MOVE_OREF_NOT_CONVERTIBLE
-
Cause: Type conflict in assignment between data references.
Runtime Error:MOVE_DREF_NOT_COMPATIBLE
-
Cause: Assignment between the involved types is not supported
Runtime Error:MOVE_NOT_SUPPORTED
-
Cause: Constants and literals cannot be overwritten
Runtime Error:MOVE_TO_LIT_NOTALLOWED
-
Cause: Constants and literals cannot be overwritten
Runtime Error:MOVE_TO_LIT_NOTALLOWED_NODATA
-
Cause: During a loop on an internal table, an attempt is made to overwrite
a reference variable that is associated with the internal table using
REFERENCE INTO
.
Runtime Error:MOVE_TO_LOOP_REF