Compatible Data Types
With assignments and
comparisons between data objects, with the exception of reference variables, the compatibility of their data types determines whether a
conversion needs to be executed or not. In the case of reference variables, the compatibility determines whether assignments or comparisons can even take place.
With assignments to field symbols or when assigning
actual parameters to
formal parameters, a typing check is executed, in which the compatibility is defined somewhat differently.
All Data Types Except for Reference Types
For all data types other than reference
types and those that contain reference types as components, the term compatibility is synonymous
for assignments and comparisons. Two data objects or their data types are compatible if all their technical type attributes match:
- In the case of elementary data objects or data types, the
built-in ABAP type, the length (for the types
c, n, p,
x), and the number of decimal places (for the type p) must match.
- Structures must have identical compositions and their components must be compatible in pairs; the
compatibility is determined by the data type of the components, just as described here. The identical
composition of structures not only refers to the sequence of the components in the memory, but also
to the combination of components into substructures. The names of the components, on the other hand, are irrelevant.
- Internal tables must have compatible row types. The table type and table key are irrelevant.
The types listed here are compatible with one another - for example, an elementary data type is never compatible with a structure, even if the latter has only one component.
Reference types can only be compatible with other reference types; data reference variables are not
compatible with object reference variables and vice versa. In the case of reference variables, the term compatibility is not synonymous for assignments an comparisons:
- With regard to comparisons, data reference variables are
compatible with all data reference variables and object reference variables are compatible with all object reference variables.
No conversion takes place for reference variables. They are either assigned to one another or compared to each other unconverted or not at all.
- This definition for the compatibility of reference variables in the case of assignments is one-way.
The type of a target reference variable, to which a source reference variable can be assigned, does
not itself have to be compatible with the type of the source reference variable. In contrast, the compatibility of reference variables in the case of comparisons is not a one-way relationship.
- If a reference variable is a component of a structure, the compatibility of the structure is determined
accordingly. In particular, the compatibility of such a structure with regard to assignments is also a one-way relationship.