ARTICLE
Assigning Fields Dynamically
In previous releases, in the
MOVE-CORRESPONDING struc1 TO struc2
statement, the field types of both structures had to be known to the
compiler. This constraint no longer applies under Unicode.
In a non-Unicode system until now, there was no problem assigning
structures with different Unicode fragment views using a
MOVE statement. In a Unicode system, such assignments
will cause a runtime error, even if both structures start with the same
types:
Example
BEGIN OF struc1, BEGIN OF struc2,
a(2) TYPE C, a(2) TYPE C,
b TYPE I, b TYPE I,
c(1) TYPE C, c(1) TYPE C,
d(4) TYPE X, g(6) TYPE P,
END OF struc 1. f(2) TYPE X,
END OF struc 2.
struc1: | aaaa | bbbb | cc | dddd |
struc2: | aaaa | bbbb | cc | gggggg | ff |
For example, the content of struc2-[a,c] (which starts with
fields of the same type) is assigned to struc1 . Until now, you
could use a simple MOVE statement (although
this could mean that the remainder of struc1 subsequently did
not contain meaningful values). However, in Unicode, you must use For
example, the content of struc2-[a,c] (which starts with fields of the
same type) is assigned to struc1. Until now, you could use a simple
MOVE statement (although this could mean that the remainder of struc1
subsequently did not contain meaningful values). However, in Unicode,
you must the MOVE-CORRESPONDING struc2 TO
struc1 ; otherwise, a runtime error occurs (because you are
attempting to MOVE struc2 to a structure with a different fragment
view). You obtain the same result in Unicode, if the field names of the
start of both structures are identical at runtime.
Documentation extract taken from SAP system, � Copyright SAP AG. All rights reserved