Skip to content

ABAP Keyword Documentation →  ABAP − Reference →  Declarations →  Declaration Statements →  Data Types and Data Objects →  Declaring Data Objects →  DATA →  DATA - BEGIN OF struc 

Declaration of a Nested Structure

This example demonstrates the declaration of a nested structure with substructures.

Other versions: 7.31 | 7.40 | 7.54

Source Code

    DATA:
      BEGIN OF address,
        BEGIN OF name,
          title   TYPE string VALUE `Mr.`,
          prename TYPE string VALUE `Duncan`,
          surname TYPE string VALUE `Pea`,
        END OF name,
        BEGIN OF street,
          name   TYPE string VALUE `Vegetable Lane`,
          number TYPE string VALUE `11`,
        END OF street,
        BEGIN OF city,
          zipcode TYPE string VALUE `349875`,
          name    TYPE string VALUE `Botanica`,
        END OF city,
      END OF address.
    cl_demo_output=>new(
      )->write( address-name
      )->write( address-street
      )->write( address-city
      )->display( ).

Description

Declaration of a nested local structure address with three structured components. When the method DISPLAY of class CL_DEMO_OUTPUT is called, each substructure is addressed using the structure component selector (-).