ABAP - Keyword Documentation →  ABAP - Reference →  Declarations →  Declaration Statements →  Data Types and Data Objects →  Types and Objects - Overview → 

Compatible Data Types

The compatibility of two data types (except reference types) is based on their technical type attributes. It is the basis for type checking in assignments to field symbols or when assigning actual parameters to formal parameters.

In the case of value assignments and comparisons between data objects (except reference variables), compatibility also determines whether a conversion has to be performed or not.

In the case of reference types with data objects (reference variables) that have a dynamic type as well as the static type, then compatibility, which is based entirely on technical type attributes, is not sufficient.

Non-Generic Data Types (Except Reference Types)

Two non-generic data types (not reference types) and data types that contain reference types as components are compatible if all their technical type attributes match.

In the case of compatible elementary data types, all these attributes match.
The layout of structured types does not only refer to the sequence of elementary components in memory, but also to the combination of components with substructures and whether a substructure is a boxed component. The names of the components and of the semantic attributes defined in ABAP Dictionary, such as conversion routines or documentation, however, are not important. In the case of compatible structures, all components are compatible in pairs. This applies recursively down to the level of elementary data types.
If two structures are both constructed identically but different substructures are declared as boxed components, the structures are not compatible.
In the case of compatible internal tables, the row types are compatible and the table category and table key match. Other attributes, such as the initial memory requirement, are not important.
Every enumerated type is unique and only compatible with itself.


Generic Data Types

A non-generic data type (not a reference type) is compatible with a generic data type if its technical attributes are covered by the generic data type.

Reference Types

A reference type is the static type of reference variables and determines to which objects they can point. At runtime, reference variables also have a dynamic type determined by the type of the object pointed to by a reference variable. The dynamic type may be more specialized than the static type. For this reason, the rules for typing checks, assignments, and comparisons cannot be covered by a compatibility concept based entirely on the technical attributes of the static type. Instead, the following three points show how reference types can be used together:

As a rule, data reference variables can only be used with data reference variables and object reference variables can be used only with object reference variables. No conversions take place between reference variables. They are either passed as unconverted reference variables, assigned to each other, compared with each other, or no action at all takes place.