ABAP Dictionary Structure

ABAP Dictionary supports creating structure types. These types can be used to create work areas in ABAP program or can be used to define parameters of function modules or methods.

A structure type consists of components that can refer to

  • data element
  • integrated types
  • table type
  • database table
  • view
  • other structure types.

We can easily include another structure inside a structure called as include structure or a nested structure. If component of structure is assigned to a database-table or a view, the data object generated from this structure remains flat and is one-dimensional.

A structure is a deep structure if it has at least one component refer to a table type. Only the component referring to table type is two-dimensional while the rest of the structure remains flat ( one-dimensional ).

Steps to create structure

  • Execute TCode SE11
  • Select radio button Data Type
  • Enter structure name and choose Create
  • Select radio button Structure in the modal dialog box and choose Continue
  • Prove a meaningful short description
  • Enter the specified components
  • From main menu choose Extras -> Enhancement Category. Select Enhancement category for structure and choose Copy.
  • Save, check and Activate the structure.

ABAP Dictionary Structure Example

Create structure with following components by referring data elements.

ABAP Dictionary Include structure example

  • Create another structure and include above structure into it. To include structure, from main menu choose Edit -> Include -> Insert. Enter Structure name and choose continue.
  • Next enter ADDRESS under component and under component type enter ADRC. Adding a structure inside another structure in known as nested structure.

The above structure is a flat structure, and all its components are one-dimensional.

You can have multiple include in a structure. In the above example, we can add the fields of ADRC table by adding ADRC table as an include structure.

Define work area by referring to structure

We can use ABAP Dictionary structure to define work areas in ABAP programs. Include structure components behave as if they are part of the same structure.

ABAP Dictionary Deep Structure example

To create a Deep structure, at least one component should refer to a table type. First create below structure.

By referring to above structure, create Table Type.

Create a component by referring to above Table Type.

Save, check and Activate the structure.

Use ABAP Dictionary Structure to define data objects in ABAP Program

In the below ABAP program we demonstrate how to define and use a data object by referring to a structure. We create a work area by referring to a structure.

*&---------------------------------------------------------------------*
*& Report ZAMARMN_STR
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT zamarmn_str.

DATA wa_empinfo TYPE zamarmn_empinfo.
DATA wa_dependent TYPE zamarmn_dependents.

*fill data into component
wa_empinfo-firstname = 'AMARMN'.
wa_empinfo-lastname = 'ACADEMY'.
wa_empinfo-gender = 'M'.

*fill data into nested component
wa_empinfo-address-house_num1 = '01'.
wa_empinfo-address-city1 = 'BENGALURU'.
wa_empinfo-address-country = 'IN'.

*the component referring to table type
*is like an internal table
wa_dependent-firstname = 'FIRST'.
wa_dependent-lastname = 'DEPENDENT'.
wa_dependent-relationship = 'FATHER'.
INSERT wa_dependent INTO TABLE wa_empinfo-dependents.

wa_dependent-firstname = 'SECOND'.
wa_dependent-lastname = 'DEPENDENT'.
wa_dependent-relationship = 'MOTHER'.
INSERT wa_dependent INTO TABLE wa_empinfo-dependents.

wa_dependent-firstname = 'THIRD'.
wa_dependent-lastname = 'DEPENDENT'.
wa_dependent-relationship = 'CHILD1'.
INSERT wa_dependent INTO TABLE wa_empinfo-dependents.

WRITE : 'Employee Name: ',
wa_empinfo-firstname,
wa_empinfo-lastname,
'Gender: ', wa_empinfo-gender.
NEW-LINE.
WRITE : 'Employee address: ', wa_empinfo-address-house_num1,
wa_empinfo-address-city1,
wa_empinfo-address-country.
NEW-LINE.
WRITE : 'Dependents: '.
LOOP AT wa_empinfo-dependents INTO wa_dependent.
  NEW-LINE.
  WRITE : wa_dependent-firstname,
  wa_dependent-lastname,
  wa_dependent-relationship.
ENDLOOP.

Output :