SAP NetWeaver AS ABAP Release 740, ©Copyright 2014 SAP AG. All rights reserved.
ABAP Keyword Documentation → ABAP − Reference → Processing Internal Data → Assignments → Assignment and Conversion Rules → Conversion Rules for Structures →Conversions Between Flat Structures
Structures Outside Unicode Programs
Outside of Unicode programs, the corresponding flat structures are regarded as single fields of type c (casting), whose length is determined by the length of their components and any alignment gaps. In this case, the assignment between the structures is performed in accordance with the conversion rules for the data type c. Most significantly, when assigning a shorter structure to a longer one, the components at the end of the target structure are not initialized according to their type but are padded with blanks.
Note
Assignments of this type are only advisable if the corresponding structures contain only character-like components.
Flat Structures in Unicode Programs
When converting flat structures in Unicode programs, the Unicode fragment view must be respected for the corresponding structures.
Conversion Rules
The following rules apply when converting a flat structure to another flat structure in Unicode programs:
No conversion rule is defined for any other cases, and assignments are not possible.
Notes
Examples
An assignment of struc1 to struc2 (and back) is not allowed in Unicode programs because the fragment views are not the same (unlike struc2-b, struc1-x only fills one byte).
DATA: DATA:
BEGIN OF struc1, BEGIN OF struc2,
a TYPE c LENGTH 1, a TYPE c LENGTH 1,
x TYPE x LENGTH 1, b TYPE c LENGTH 1,
END OF struc1. END OF struc2.
Assignments of struc3 to struc4 and vice versa are allowed because the fragment view of the shorter structure struc3 is the same as the fragment view in the first part of the longer structure struc4.
DATA: DATA:
BEGIN OF struc3, BEGIN OF struc4,
a TYPE c LENGTH 2, a TYPE c LENGTH 8,
n TYPE n LENGTH 6, i TYPE i,
i TYPE i, d TYPE decfloat16,
END OF struc3. END OF struc4.
Assignments of struc5 to struc6 and vice versa are also not allowed because the fragment views in the two structures do not match due to the alignment gaps before struc5-b and before struc6-struc0-b.
DATA: DATA:
BEGIN OF struc5, BEGIN OF struc6,
a TYPE x LENGTH 1, a TYPE x LENGTH 1,
b TYPE x LENGTH 1, BEGIN OF struc0,
c TYPE c LENGTH 1, b TYPE x LENGTH 1,
END OF struc5. c TYPE c LENGTH 1,
END OF struc0,
END OF struc6.
An assignment of struc7 to struc8 and vice versa is possible because the fragment view is the same until the second last fragment p in the shorter structure struc7:
DATA: DATA:
BEGIN OF struc7, BEGIN OF struc8,
a TYPE i,
a TYPE i,
p TYPE p LENGTH 8, p TYPE p LENGTH 8,
c TYPE c LENGTH 1, c TYPE c LENGTH 5,
END OF struc7. o TYPE p LENGTH 8,
END OF struc8.
A mapping from struc9 to struc10 (and in the reverse direction) is possible because the fragment view matches despite the differences in decimal places for the type p. If struc9-a has the value 999, then struc10-a has the value 0.999 after a mapping from struc9 to struc10. A direct mapping from struc9-a to struc10-a, on the other hand, raises an exception of the class CX_SY_CONVERSION_OVERFLOW.
DATA: DATA:
BEGIN OF struc9 BEGIN OF struc10,
a TYPE p LENGTH 2 a TYPE p LENGTH 2
DECIMALS 0,
DECIMALS 3,
END OF struc9. END OF struc10.