Defining Dictionary Structures


After completing this lesson, you will be able to:

  • Define dictionary structures

Dictionary Structures

Dictionary structures can be used as data types in the ABAP dictionary.

The structure on the left-hand side of our example consists of five components. The first four components reference various data elements. The last component is typed with predefined dictionary type CHAR, directly.

The ABAP code on the right-hand side defines exactly the same structure type using the TYPES statement. This code could be located in a method, in the definition part of a class, or in an interface. The first four components use the same data elements as the components in the dictionary structure. The last component uses built-in ABAP type C.

Apart from the extensibility and the label, the two structures are fully compatible.

Nested Structures

Nested structure types in ABAP dictionary

Play the video to learn about nested structure types in ABAP dictionary.


When you type a data object with a nested structure type, you have to access its components as follows:

Code snippet
  gs_struct-address-post_code = '69190'.
  gs_struct-address-city      = 'Walldorf'.

It is not possible to access the sub-components of the address directly.

How to Define a Nested Structure

Play the video to see how to define a nested structure.

Include Structures

Nested structures must not be confused with structures that include another structure type.

Earlier in this course, you learned how to include a structure into the field list of a database table. The same technique is available when defining a structure type.

In the example, structure zs4d430s_person_include has a total of seven components: Components first_name and last_name are defined in the structure directly, while the other five components are added by including structure type zs4d430s_address.

The ABAP code on the right-hand side illustrates how you can define the same type using the TYPES statement in an ABAP class or interface.

To understand this code, you have to be aware, that INCLUDE TYPES is a statement of its own and not an addition to statement TYPES. The TYPES chain statement is finished before the INCLUDE statement with a period sign (.) and a new TYPES chain statement begins after the INCLUDE statement.

When you use such a structure type in ABAP, the include is not visible. You access the additional components as usual:

Code snippet

  gs_struct-first_name = 'John'.
  gs_struct-post_code  = '69190'.
  gs_struct-city       = 'Walldorf'.

Named Includes

When you include a structure into another structure, you can give the include a name. This include is then called a named include.

In the ABAP dictionary, you add the name before the keyword INCLUDE and separate the two by a colon sign (:). When you define your structure type in ABAP, you place the name after the name of the include structure, with keyword AS in front of it.

The named include establishes a kind of a field group that allows you to access the fields not only directly but also through the name of the include.

Let us consider a data object struct that is typed with structure type zs4d430s_person_include. You can access field city in two ways: Either as struct-city as you would with a normal include, or as struct-address-city.

Named includes and field groups are used a lot in the derived data types of the ABAP RESTful application programming model.

How to Include Structures

Play the video to see how to include structures.

Log in to track your progress & complete quizzes