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 possible alignment gaps. In this case, the assignment between the structures takes place according to 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 filled with blanks.
Assignments of this type are only advisable if the corresponding structures contain only character-like components.
When converting flat structures in Unicode programs, you must bear in mind the Unicode fragment view for the corresponding structures.
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, so that assignment is not possible.
If a syntax error occurs due to an inadmissible assignment between flat structures, you can display the fragment views for the corresponding structures when displaying the syntax error in the ABAP Editor by choosing the pushbutton with the information icon.
Assigning struc1 to struc2 and vice versa 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,
f TYPE f,
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.