[ABAB] Struct (Datentyp) definieren

Einfaches Beispiel

* Definition
TYPES: BEGIN OF s_adresse,
         knr(8)  TYPE n,
         name    TYPE string,
         vorname TYPE string,
         plz(5)  TYPE n,
         ort     TYPE string,
       END OF s_adresse.

* Variable vom Typ
DATA: adresse TYPE s_adresse.

* Zugriff
adresse-knr = '1234'.
adresse-name = 'Hoffmann'.
adresse-vorname = 'Horst'.
adresse-plz = '01069'.
adresse-ort = 'Dresden'.

* Ausgabe
WRITE:  / adresse-knr,
        / adresse-name,
        / adresse-vorname,
        / adresse-plz,
        / adresse-ort.

Verschachtelung von Structen

TYPES: BEGIN OF s_type1,
         num TYPE i,
         name TYPE string,
       END OF s_type1.

TYPES: BEGIN OF s_type2,
         col TYPE i,
         text TYPE string,
       END OF s_type2.

TYPES: BEGIN OF s_mystruct,
         a TYPE s_type1,
         b TYPE s_type2,
       END OF s_mystruct.