Start of Content Area

Data Layout of Structures  Locate the document in its SAP Library structure

For several data types such as I and F or object references, certain alignment requirements are in place that depend on the platform used. Fields of these types must begin in memory at an address divisible by 4 or 8. Character-type types must begin at a memory address divisible by 2 or 4 depending on their Unicode representation.

Within structures, bytes can be inserted before or after components with alignment requirements to achieve the necessary alignment. These bytes are referred to as alignment (A). A substructure is aligned according the field with the biggest alignment requirement. In this case a contained substructure counts as a field. Includes in structures are treated as substructures.

In the sample structure below that contains three fields, no alignments are created in an NUS or US.

BEGIN OF struc1,
  a(1) TYPE X,
  b(1) TYPE X,
  c(6) TYPE C,
END OF struc1.

In the next example, however, alignments are created in a US but not in an NUS. The first alignment gap is created because of the alignment of structure struc3, the second because of the alignment of C field c, and the third because of the addressing of integer d.

BEGIN OF struc2,
  a(1) TYPE X,
  BEGIN OF struc3,
    b(1) TYPE X,
    c(6) TYPE C,
  END OF struc3,
  d TYPE I,
END OF struc2.

This graphic is explained in the accompanying text

End of Content Area