ABAP Keyword Documentation → ABAP - Reference → Assignments → Assignment Rules → Conversion Rules for Structures → Conversion Between Flat Structures
Conversion Rules for Structures
This example demonstrates how structures can be converted from one type to another.
Other versions: 7.31 | 7.40 | 7.54
Source Code
DATA: BEGIN OF fs1,
int TYPE i VALUE 5,
pack TYPE p DECIMALS 2 VALUE '2.26',
text TYPE c LENGTH 10 VALUE 'Fine Text',
float TYPE decfloat16 VALUE '1.234e+05',
date TYPE d VALUE '19950916',
END OF fs1.
DATA: BEGIN OF fs2,
int TYPE i VALUE 3,
pack TYPE p DECIMALS 2 VALUE '72.34',
text TYPE c LENGTH 5 VALUE 'Hello',
END OF fs2.
WRITE: / fs1-int, fs1-pack, fs1-text, fs1-float, fs1-date.
WRITE: / fs2-int, fs2-pack, fs2-text.
MOVE fs1 TO fs2.
WRITE: / fs2-int, fs2-pack, fs2-text.
Description
In this example two different structures are defined, fs1
and fs2
. The requirements of the third
conversion rule for flat structures apply to
both structures and the corresponding rule is also used. After the assignment of fs1
to fs2
, only the result for the first two components is as if they had been transferred component by component.
fs2-text
is filled with the first five positions from fs1-text
. All the remaining elements of fs1
are not transferred.