Table Type in SAP ABAP

by | May 13, 2018 | ABAP Beginner

Home » SAP » ABAP » ABAP Beginner » Table Type in SAP ABAP

Preface – This post is part of the ABAP Beginner series.

Table Type in SAP ABAP

Before discussing Table Type in SAP ABAP, it will be good to understand Internal Tables first.

An Internal table is a runtime object which holds runtime data in form of table. Its data type is specified by its line type, key and table type. Line type tells the data type of an internal table which can be a structure, a table, an internal table or any data type. Keys are the one which helps to identify each row. Table type specifies how ABAP will access these internal tables i.e. standard table, sorted table & hashed table.


In ABAP Program you can also define Internal Table of type “TABLE TYPE”:


Here TTYP stands for Table Type.

In this particular case you don’t need to take care of any other properties of internal table, it will be taken care by Table Type.


A Table Type in SAP ABAP is a global reusable object which is used to define structure and functional attributes of an internal table in ABAP.

A table type is defined by:

  • Line Type: It defines the structure and data type
  • Access Mode: kind of internal table e.g. Sorted, Hashed, Indexed
  • Keys: Primary & Secondary keys of the table

Creation of Table Type in SAP ABAP:

#Using ABAP Dictionary

Step 01: Open SE11.

Step 02: Click Data Type Radio Button and select Table Type radio button from the given radio buttons.  Give your Table Type name starting with Z or Y e.g. “ZBarry_ttype”.

Step 03: Click Create, Enter explanatory description for table type in Short Description e.g. “Table Type for Test”.

Step 04:  On Line Type tab, maintain one of the following:


Line TypeEnter name of any of the following:

A data element, a structure, a table, a view or even a table type

Table Type will create a structure similar to this line type.
Predefined TypeEnter Data Type, Field Length & decimal placesLength Type can be any predefined data types with any length of field and decimal places. It is similar to the creation of Data Elements.
Reference TypeEnter either name of a class, an interface, a generic reference to ANY, OBJECT, or DATA or a reference to a type defined in the Dictionary.Reference type creates a pointer to data object



Step 05: On the Initialization and Access tab, maintain the following:

Initial Line NumberEnter any numeric value if you know the number of records

Note: You can leave it empty.

Just Like OCCURS statement in ABAP Internal Table, here too we can specify the number of Initial lines occupied by the internal table.
Access: It defines the way Internal table data is accessed while performing the SQL operations on the internal table. Choose one of the following given below:


Access ModeDescription
Standard tableIt uses linear search to access key.
Sorted tableIt is sorted internally on basis of key. It uses binary search to access key.
Hashed tableIt is sorted internally on basis of hashed key. The hash key is generated for each key and this key is used to access data irrespective of index. Hashed keys are generated using Hash Algorithm internally.
Index tableIn this case the table can be Standard or Sorted. It allows Index access for such table. Index tables are used to define generic parameters of a Subroutine Form & Function Module.
Not SpecifiedIt means table can be any among Standard, Sorted or Hashed. The access of Index is not allowed here.


Step 06: On the Key tab, maintain the following:

Key Definition: It specifies the Primary key of the table. Select one of the following:
Standard keyIt defines the key of Table Type on basis of Line type. The Key contains all the character fields of the table line in case of structure, table or view and It is the entire table line in case of Data Element or Reference type.
Line typeIt defines the entire fields of line type as Primary key.
Key componentsWe can select Primary key from the structure specified by us in Line Type tab earlier. In this case, we need to select the Primary keys.
Key not specifiedIn this case key is Generic. And the table type is called Generic Table Types.
Key Category: It tells whether our table type will make an internal table that can store only Unique keys or can have duplicates also.
UniqueIt means internal table can have only unique records.
Non-UniqueIt means internal table can have duplicate records too.
Not specifiedIt can be any Unique or Non-Unique. It defines Generic Table Types.
Key ComponentsIf you have chosen Key components in Key Definition tab, than you must click on the button Choose components and choose the required fields.


Note: Here table line means structure of line type.

Combination of Access Mode and Key category that is allowed:

Access ModeKey categoryDescription
Not SpecifiedNot specifiedIt means that if the access mode is the one as mention here, than the key categories must be chosen from this table only.
Index TableNot specified
Standard TableNon-Unique
Sorted TableUnique, Non-Unique or Not specified
Hashed TableUnique


Step 07: Once all the above fields are maintained, save, check for errors and activate your table type.


Advantages of Table Type in SAP ABAP:

  1. For an Internal table, you might need to create a local structure using types, state its type, and state its other properties. By using table types, we need to just declare the internal table of type Table Types, rest will be taken care by the table types.
  2. Being a global object, it can be reused.


Note: Table Types is a vast topic and it needs one more article to explain the rest of the concepts like Ranges Table Types, etc. We will cover them in next article.

1 Comment

  1. RAVI GR

    very use full article thank you for sharing this :).


Submit a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.