ABAP Keyword Documentation → ABAP − Reference → Processing Internal Data → Assignments → Assignment and Conversion 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.
DATA(out) = cl_demo_output=>new(
)->begin_section( 'Source'
)->write( |{ fs1-int width = 10 } {
fs1-pack width = 10 } {
fs1-text width = 10 } {
fs1-float width = 10 } {
fs1-date width = 10 }| ).
out->next_section( 'Target'
)->write( |{ fs2-int width = 10 } {
fs2-pack width = 10 } {
fs2-text width = 10 }| ).
fs2 = fs1.
out->next_section( 'Result'
)->display( |{ fs2-int width = 10 } {
fs2-pack width = 10 } {
fs2-text width = 10 }| ).
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 rule in question is also applied. After the assignment of fs1
to fs2
, only the result for the first two components is the same as if they
were passed component by component. fs2-text
is filled with the first five
places from fs1-text
. None of the remaining elements of fs1
are passed.