SAP MOVE OBS ABAP Statements



Get Example source ABAP code based on a different SAP table
  


ID MOVE
• MOVE ABAP Statement
• TO MOVE (obsolete)
• ?TO MOVE (obsolete)
• EXACT MOVE (obsolete)

MOVE
Short Reference

ABAP_SYNTAX_OBS
MOVE ${$[EXACT$] source TO destination$}
$| ${ source ?TO destination$}.

ABAP_VARIANTS:
1 MOVE $[EXACT$] source TO destination.
2 MOVE source ?TO destination.

What does it do?
Obsolete form of the assignment of data objects and reference variables source to target variables destination. If EXACT is specified, only data objects can be specified for source. If EXACT is not specified, the following can be specified for source alongside data objects:
Functional method calls
Certain built-in functions
The following cannot be specified with MOVE:
Constructor expressions, table expressions, and calculation expressions for source
An inline declaration DATA(var) or FINAL(var) or a writable expression for destination.



Latest notes:

Instead of MOVE, only the more general assignment operators = and ?= should be used, which enable a more general concept.
The option to specify functional methods and some built-in functions as assignment sources was added to the source position of the statement MOVE, which was originally designed only for assigning data objects, making this source position an extended functional operand position. This does not, however, cover all the possible functions of assignment operators. New developments, such as specifying constructor expressions, table expressions, or inline declarations are now only made possible for assignment operators.
ABAP_HINT_END

ABAP_VARIANT_1 MOVE $[EXACT$] source TO destination.

What does it do?
Without the addition EXACT, this statement works in the same way as destination = source.
If the addition EXACT is specified, the statement works like destination = EXACT #( source ).
In this way, the addition EXACT produces a lossless assignment in accordance with the rules that apply when using the lossless operator EXACT. This can raise exceptions if values are lost or if they are invalid. If an exception is raised when the operator EXACT is used, the statement is not executed, and the value of the target field remains unchanged. In assignments made without the operator EXACT, the target field contains an undefined value when an exception raised by the conversion is handled.



Latest notes:

When MOVE is used for enumerated objects, addition EXACT and the lossless operator EXACT have the special effect that they can enable assignments, which would otherwise have not been possible.
ABAP_HINT_END



Example ABAP Coding

The two commented out assignments of a number to the enumerated variable num is not possible. The assignment is possible using EXACT, because in this case the assignment follows the same rules as the lossless operator shown below.
ABEXA 00448
ABAP_EXAMPLE_END

ABAP_VARIANT_2 MOVE source ?TO destination.

What does it do?
This statement works in the same way as destination ?= source.
source and destination must have reference types. The addition ?TO makes downcasts possible, whereas in TO only upcasts can be used.

ABAP_PGL
Assignments with the assignment operators = and ?= only
ABAP_PGL_END

Return to menu