Defining Dictionary Table Types


After completing this lesson, you will be able to:

  • Define a dictionary table type
  • Define a nested table type

Dictionary Table Types

Creating a dictionary table type

Play the video to learn about creating a dictionary table type.

Dictionary table types

The editor for dictionary objects of type Table Type is form-based and not code-based as the editors are for structures and database tables. The editor consists of the following four sections:

Select each section to learn more.

When we compare the definition of a dictionary table type and a table type that is defined with ABAP statement TYPES, you can easily identify the different parts:

  • The row type is specified after the addition OF.
    The syntax of the TYPES statement only allows one word here. When using an ABAP built-in type that requires a length (incomplete ABAP type), the row type has to be defined in a separate TYPES statement.
  • The table access category is specified after the addition TYPE.
  • The primary key definition is specified after the addition WITH. Key definition value Row Type, corresponds to table_line in the ABAP syntax.

Options for Defining the Row Type

When you define a table type you have several options to specify the row type:

Dictionary Type
This is the most common row type category. The row type is specified though another dictionary object, most often a structure. If the row type is a data element, the internal table will have one column only that does not have a name to it.
Predefined Type
Technically, using a predefined type as row type is identical to using a data element. What is missing is the additional semantics of a data element.
Reference to
With one of these options the row type is a reference type. The internal table will have one nameless column containing a list of references, either to data objects or to instances of classes.
Range Table on
With one of these options the table type defines the type of a ranges table. Although you specify only a predefined type or a data element, the ranges table will have four columns: OPTION, SIGN, LOW, and HIGH. For more information on the usage of ranges tables refer to the ABAP documentation.

When you define the row type of a new table type, you can search for existing dictionary types. You will find data elements, structures, but also database tables and table types. Place the cursor in the input field Type Name and press Ctrl + Space, or choose Browse.

If the specified dictionary type exists, a left-click on Type Name navigates to the definition.
Even though table types are offered here it is not meaningful to use them as row types. The resulting "Table of Tables" is difficult to handle because there is no easy way to identify the rows of the outer table. Use structures with table-like components instead. We will discuss those nested tables later.

Access Category and Keys

Access category

The table category is a technical property of the table type that specifies the storage and primary access method. The default value is Standard Table. Other values are:

Select each value to learn more.

For defining the primary key of a table type the following options exist:

Standard Key

The standard key (also known as default key) consists of all non-numeric components of the row type.

Row Type

With this option the primary key consists of all components of the row type. If the row type is unstructured, the one column is the key column.

Not Specified

With this option no primary key is defined. The table type is generic and cannot be used for ABAP data objects.

Key Components

The primary key consists of the explicitly specified components. When you choose this option, the editor displays a new section below the Primary Key Details section. In this section you enter must then enter the key components.

Press Ctrl + Space to choose from the components of the row type.
Remember that the primary key of internal tables is not necessarily unique. For standard tables and sorted tables, non-unique primary keys are also supported. For standard tables it is actually the only option. This is opposed to database tables where the primary key is always a unique key.

Secondary key definition

Play the video to learn about secondary key definition.

How to Define a Dictionary Table Type

Play the video to see how to define a Dictionary Table Type.

Nested Table Types

You can use a table type to type the component of a structure type. In the example, component addresses is typed with table type zs4d430T_addresses. The ABAP code on the right-hand side illustrates how you define exactly the same structure type in ABAP.

A structure with a table-like component is often referred to as a deep structure. The opposite is a flat structure. This has to do with the memory layout of such a data object in ABAP. For details on deep and flat structures, refer to the ABAP documentation.

When you use a structure with a table-like component as row type of another table type, this table type becomes nested. In the example, structure ZS4D430S_PERSON_DEEP is used as row type of table type ZS4D430T_NESTED. Column addresses of the resulting internal table contains an internal table in each row.

In each row of the outer table, the inner table can have a different number of rows.

Log in to track your progress & complete quizzes