SAP ALIGNMENT

Get Example source ABAP code based on a different SAP table
  


ARTICLE

Alignment of Data Objects
Data objects with the following data types cannot simply be stored at random addresses in the main memory:
Numeric data objects of types i,
int8, decfloat16, decfloat34, and f
Deep data objects
Character-like data objects in Unicode systems
For example, an ABAP field with the type i must have an address divisible by four, a field with the type
int8, 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, depending on the Unicode 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.
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.

Notes
ABAP Code Snippet ABAP Code Snippet substructures with regard to alignment.
The binary content of alignment gaps is not defined and cannot be evaluated.