SAP ALIGNMENT



Get Example source ABAP code based on a different SAP table
  



Alignment of Data Objects
Data objects with certain data types cannot be stored in random addresses in the main memory:
Numeric data objects The memory address of ABAP fields with the following numeric types must be divisible as follows:
s by 2
i by 4
int8, decfloat16, f by 8
decfloat34 by 16
Character-like data objects The memory address of character-like data objects must be divisible by 2 for the character representation UCS-2 used by the ABAP programming language.
Time stamp fields The memory address of time stamp fields of the type utclong must be divisible by eight.
Deep data objects The memory address of deep data objects such as strings or reference variables must be divisible by 4.
An elementary data object is aligned when it has an address that corresponds to its data type.
A structure is aligned if:
Its start address meets the strictest alignment requirements of its components and
The offsets of all components meet the same type-specific divisibility requirements.
Normally, the correct alignment of data objects is not normally an issue, because they are automatically created correctly during declaration. This can cause alignment gaps in structures with components of different data types.
However, correct alignment must be checked in the following cases:
In assignments and comparisons of structures where the structure fragment view that splits a structure into fragments in accordance with its alignment gaps must be considered.
When a data object is handled using explicit or implicit casting with a different data type.
When a work area that has a different type from the database table is used in an AB-SQL statement.
If a statement expects a specific alignment of a data object, an exception is raised when there is insufficient alignment.



Latest notes: