Skip to content

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

Alignment of Data Objects

Data objects with the following data types cannot simply be stored at random addresses in the main memory:

For example, an ABAP field with the type i must have an address divisible by four, a field with the type f or decfloat16 must have an address divisible by eight, and a field with the type decfloat34 must have an address divisible by 16. The storage address of character-like data objects must be divisible by 2 or 4 in a Unicode system, depending on the Unicode representation. See also Alignment of Character-Like Data Objects.

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.

The correct alignment of data objects is not normally an issue, because they are created correctly automatically in the declaration. This can lead to alignment gaps in structures with components of different data types.

However, the alignment must be checked in the following cases:

  • 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


Notes

  • The binary content of alignment gaps is not defined and cannot be evaluated.

  • Alignment gaps can also occur at the end of structures, as the overall length of the structure is determined by the component with the largest alignment requirement.

  • Alignment gaps are included in the length of a structure.

Continue

Alignment of Character-Like Data Objects