Move & Compute:
MOVE source TO target.
COMPUTE target = source.
DATA : d1(4),
d2 TYPE I VALUE 75,
d3 TYPE I.
MOVE ‘SAP’
TO d1.
COMPUTE d3
= d2 + 125.
If source & target fields have different type
then source is converted in the format of target.
Basic Assignment Operations
Assigning values with Offset specifications
Copying values between components of Field Strings
Basic Assignment Operations
Syntax: MOVE
<f1> TO <f2>
The MOVE statement transports the contents of the
source field <f1>, which can be any data object, to the target field
<f2>
The MOVE statement and the assignment operator have
the same function. The above statement when written with assignment operator
(=) has the form:
f2 = f1.
Example:
DATA: T(10),
NUMBER TYPE P DECIMALS 1,
COUNT TYPE P DECIMALS 1.
T =
1111.
MOVE ‘ 5.3 ‘
TO NUMBER.
COUNT =
NUMBER.
The result of this assignment is that fields T,
NUMBER, and COUNT contain the values ‘ 1111 ’, ‘ 5.3 ‘, and ‘ 5.3 ‘.
Assigning values with Offset specifications
You can Specify offsets and lengths for elementary
data objects in every ABAP/4 statement.
Syntax:
MOVE <f1> [+<p1>][(<l1>)] TO
<f2> [+<p2>][(<l2>)].
The contents of the section of field <f1>,
which begins at the position <p1>+1 and has a length of <l1>, are
assigned to field <f2> where they overwrite the section which begins at
the position <p2>+1 and has a length of <l2>.
In the MOVE statement, all offset and length
specifications can be variables.
Example:
DATA:F1(8) VALUE
‘ABCDEFGH’,
F2(8).
DATA:O TYPE I VALUE 2,
L TYPE I VALUE 4.
MOVE F1 TO
F2.
Write / F2.
MOVE F1+O(L) TO
F2.
Write / F2.
MOVE F1 TO F2
+O(L).
Write / F2.
CLEAR F2.
MOVE F1 TO F2
+O(L).
Write / F2.
MOVE
F1+O(L) TO F2+O(L).
Write / F2.
The above example produces the following output:
ABCDEFGH
CDEF
CDABCD
CDEF
Copying values between components of Field Strings
Syntax:
MOVE-CORRESPONDING <STRING1> TO <STRING2>.
This statement assigns the contents of the
components of field string <string1> to those components of field string
<string2> which have the same names.
The system executes a MOVE statement for each name
pair as follows:
MOVE STRING1- <component> TO STRING2-
<component>