Compatibility of Data Types

When working with data, you occasionally convert data from one type to another. To do this, the data types must be convertible (see Type Conversions). An important prerequisite for convertibility is compatibility.

If two data types have the same technical properties, they are compatible.

The consequences for the different ABAP data types are as follows:

Elementary Data Types

Elementary data types are compatible with other elementary data types if they are identical in type, size, and (for type P) the number of digits after the decimal point.

Elementary data types and structured data types are not compatible with each other.

Structured Data Types

With structured data types, you must distinguish between field strings and internal tables.

Structures

Structures are compatible with other field strings if their structures are identical and their components are compatible. This means that the way in which structures are constructed from elementary fields to form the overall structure from sub-structures must be the same and their elementary components must be compatible with each other. The pairs of elementary components must be compatible. If two structures consist of the same sequence of elementary fields, but these fields are combined differently to substructures, the structures are not compatible.

Structures are not compatible with elementary data types and internal tables.

Internal Tables

Internal tables are compatible with other internal tables if their line types are compatible. The compatibility of internal tables does not depend on the number of lines.

Internal tables are not compatible with structures and elementary data types.

In this context, compatibility between data types always refers to fully specified data types, since every data type which occurs at runtime of an ABAP program is fully specified (e.g. the length of a data type C is always defined and known). This compatibility is symmetrical.

In connection with the typing of formal parameters and field symbols a somewhat different, unsymmetrical compatibility is used (see Typing Formal Parameters and Typing Field Symbols).