ABAP Keyword Documentation → ABAP - Reference → Declarative statemnts → Data Types and Data Objects → Types and Objects - Overview → Data Objects
Alignment of data objects
You cannot store data objects of the following data types at any addresses you want in the main memory:
- Numeric data objects
For example, an ABAP field of type
i must have an address divisible by 4,
and a field of type
decfloat16 must have
an address divisible by 8, a field of type
decfloat34 must have an address
that is divisible by 16. The storage address of character-like data objects must be divisible by 2 or 4, depending on the
Unicode character representation.
An elementary data object is aligned when it has an address that corresponds to its data type.
A structure is aligned when
- Its start address satisfies the strictest alignment requirements of its components and
- The offsets of all components satisfy the same type-specific divisibility requirements.
You do not normally have to be concerned about the correct alignment of data objects, because they are automatically created correctly on declaration. This can lead to alignment gaps in structures with components of different data types.
However, in the following cases, you must pay attention to alignment:
- When a data object is handled using explicit or implicit casting with another data type
- When a work area that has a different type to the database table is used in an Open SQL statement
- When offset/length specifications are used in non-Unicode systems to access components of structures, because the offset of a component of a structure may not be equal to the sum of the lengths of the previous components, because of alignment gaps.
If a statement expects a particular alignment of a data object, an exception is raised if there is insufficient alignment.
Other versions: 7.31 | 7.40 | 7.54
Components that are included in structures using
INCLUDE TYPE|STRUCTURE behave like genuine
substructures with regard to alignment.
- The binary content of alignment gaps is not defined and must not be evaluated.