MOVE is a keyword used in SAP ABAP programming.
This tutorial covers its introduction & syntax details.
1. MOVE f TO g.
2. MOVE f+off1(len1) TO g+off2(len2).
3. MOVE c1 TO c2 PERCENTAGE n.
MOVE f TO g.
Moves the contents of field f to field g . Field f remains unchanged.
This statement is equivalent to:
g = f.
DATA: NUMBER TYPE I,
FIVE TYPE I.
MOVE 5 TO FIVE.
MOVE FIVE TO NUMBER.
The fields NUMBER and FIVE now both 5.
Multiple assignments like
NUMBER = FIVE = 5.
are also possible. ABAP/4 executes them from right to left (as in the above example).
the field types or lengths differ, type conversion follows
automatically. Type I fields are handled like type P fields. If you
select the fixed point arithmetic attribute for an ABAP/4 program, type
P fields are either rounded according to the number of decimal places
or filled with zeros.
In contrast to WRITE TO , the decimal character is always a period (.), regardless of the specification in the user master.
MOVE allows you to copy tables and structures which contain other tables.
tables can be copied only if this is possible for their respective
lines. If the line types are incompatible, conversions are performed
line by line. If itab is a table with a header line, the table itself
can be addressed with itab .
Two structures which themselves
contain tables can only be copied if they are compatible (i.e. if the
ABAP/4 type check allows this).
Conversion table ( f -> g ) depending on the types of f and g :
-> C Left-justified transfer. If the target field is longer than the
source field, it is padded with blanks on the right. If it is shorter
than the source field, the left part of the source field is copied and
the rest is truncated. C -> D The field f must be an 8-character
date in YYYYMMDD format. C -> F The character string in f must be a
valid representation of a floating point number (DATA ). C -> N Only
the digits in f are valid here. They are moved to g , right-justified
and padded with zeros on the left. If the target field is too short,
digits on the left are truncated. C -> T The field f must contain a
6-character time specification in HHMMSS format. C -> P the field f
must contain a decimal number, i.e. a sequence of numeric characters
with optional signs and more than once decimal point; there may be
blanks on either side. If g is too short, an overflow error can occur.
C -> X The field f must contain a hexadecimal character string (i.e.
the only valid characters are 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F). The
number to be converted is treated as a hexadecimal number rather than a
e.g.: C’15’ -> X’15’ .
It is transported left-justified to g and either padded with zeros or truncated,
e.g.: C’AB’ -> X’AB00′ .
f is processed up to the first blank.
C’ABC’ -> X’ABC0′, C’ABC0′ -> X’ABC0′
C’ABC D’ -> X’ABC0′, C’ AB’ -> X’0000′
-> C Left-justified transfer without conversion D -> D Transfer
without conversion D -> F As for D -> P and then P -> F D
-> N As for D -> C and then C -> N D -> P Inverse of P
-> D D -> T Not supported: Error message D -> X Inverse of X
F -> C f is converted to E format and moved to g . E.g.: F’-3.142′ -> C’-3.14200000000000E+00′
If the mantissa is unequal to 0, it is standardized so that it lies between 1.0 and 9.99…
The exponent is generally 2-digit; it is only converted to 3-digit format if it is greater than 99 or smaller than -99
The exponent always appears with a sign.
If g is too short, the mantissa is rounded.
e.g.: F’3.152′ -> C’ 3.2E+00′ .
length of g should be at least 6, otherwise it g is filled with
asterisks (*). F -> D See F -> N F -> F Transfer without
conversion F -> N f is rounded as with F -> P and then treated
like a P field. F -> P f is rounded, e.g. F’-3.512′ -> P’-4′ . F
-> T See F -> N F -> X See F -> N
N -> C f is treated
like a C field; leading zeros remain. N -> D As for N -> C and
then C -> D N -> F As for N -> P and then P -> F N -> N
Right-justified transfer; on the left, padded with zeros or truncated.
N -> P f is packed and moved to g with a positive sign (+). If g is
too short, an overflow error can occur. N -> T As for N -> C and
then C -> T N -> X As for N -> P and then P -> X
P -> C f is moved to g with a trailing sign and, if required, a decimal point.
e.g.: P’-1234567′ -> C’12345.67-‘
1) One position is always reserved for the sign and, in the event of a positive number, a blank is output.
2) Leading zeros are output as blanks.
If g is too short, the blank representing the sign in the case of
positive numbers is omitted; if this is insufficient, the number is
truncated on the left – this is indicated by an asterisk (*).
Examples (the P field f has the length 2, the C field g the length 3):
P’123′ -> C’123′, P’-123′ -> C’*3-‘
4) If you do not want to reserve a position for the sign, use the WRITE TO statement with the addition NO-SIGN .
To convert with leading zeros and without formatting characters, use
the UNPACK statement. P -> D The value in f is the absolute date
(i.e. the number of days since 01.01.0001) and is moved to g in the
YYYYMMDD format. This takes into account that the Julian Calendar was
replaced by the Gregorian Calendar on 15.10.1582. The value 0 (and
negative values) are transferred into the initial date ‘00000000’. P
-> F The field f is moved to g as a floating point number. P -> N
Right-justified transfer without sign; padded with zeros on the left. P
-> P If g is too short, an overflow error can occur. P -> T The
value in f is an absolute time (i.e. the number of seconds since
midnight modulo 24 hours = 86.400 seconds) and is moved to g in HHMMSS
format. P -> X The value in f is stored in g as a hexadecimal
number. E.g.: P’15’ -> X’0F’ .
Negative numbers are represented by the two’s complement.
e.g.: P’-153′ -> X’FF67′ .
the length of g is greater than 4, only the last 4 Bytes are provided
for according to the value of f ; the Bytes before them are padded with
If g is too short, the number is truncated on the left.
-> C As for D -> C T -> D Not supported: Error message T ->
F As for T -> P and then P -> F T -> N As for T -> C T
-> P Inverse of P -> T T -> T Transfer without conversion T
-> X Inverse of X -> T
X -> C f is converted to hexadecimal
format. The result is transferred left-justified and padded with blanks
or truncated on the right.
e.g.: X’0F’ -> C’0F’ X -> D The
value in f is an absolute date (number of days since 01.01.0001) and is
moved to g in YYYYMMDD format. (See also P -> D.) X -> F As for X
-> P and then P -> F X -> N As for X -> P and then P ->
N X -> P f is treated as a hexadecimal number and moved to g in
decimal packed format.
e.g.: X’0F’ -> P’15’
If f is longer than 4, only the last 4 bytes are processed.
g is too short, an overflow error can occur. X -> T The value in f
is an absolute time (i.e. the number of seconds since midnight modulo
24 hours = 86,400 seconds) and is moved to g in HHMMSS format. (See
also P -> T.) X -> X Left-justified transfer; padded with X’00’
on the right or truncated.
BCD_BADDATA : Source field (type P ) does not contain the correct BCD format
BCD_FIELD_OVERFLOW : Result field defined too small (type P )
BCD_OVERFLOW : Arithmetic operation overflow (type P )
CONVT_NO_NUMBER : Source field cannot be interpreted as a number
CONVT_OVERFLOW : Source field conversion overflow
MOVE_COMPLEX_OVERLAP : Assignment not allowed for deep structures in case they overlap
MOVE_NOT_SUPPORTED : Assignment between types involved is not supported
MOVE_TO_LIT_NOTALLOWED : Constants and literals must not be overwritten
Related COMPUTE , WRITE TO
MOVE f+off1(len1) TO g+off2(len2).
With offset off2 and length len2 , field g receives the contents of field f with offset off1 and length len1 .
Therefore, the offset and length specifications can also be variable.
DATA: FIELD1(10) VALUE ‘1234567890’,
OFF1 TYPE I VALUE 1,
LEN1 TYPE I VALUE 2,
FIELD2(8) VALUE ‘abcdefgh’,
OFF2 TYPE I VALUE 3,
LEN2 TYPE I VALUE 4.
MOVE FIELD1+OFF1(LEN1) TO FIELD2+OFF2(LEN2).
FIELD2 now has the value ‘ abc23 h ‘.
MOVE c1 TO c2 PERCENTAGE n.
1. … LEFT
2. … RIGHT
and c2 must be type C fields; n is a field with a numeric value between
0 and 100. The left part of field c1 ( n percent) is moved to field c2
and is left-justified. c2 is filled with blanks if necessary.
This is the standard. With this statement, you can make clear that transfer is to be left-justified.
Transfer is right-justified, the left part of field c1 as standard.
The runtime required to transfer a C(1) field to a C(1) field is 1 msn (standard microseconds).
should be avoided for performance reasons, i.e. the fields should have
the same type and length. For example, a MOVE of a C(10) field to a
C(10) field takes about 2 msn, while a MOVE of a C(10) field to a type
I field needs about 10 msn.