Data Type of an Internal Table
- Row Type
The row type of an internal table can be any data type. If the row type is structured, the individual components of a row are also known as the columns of the internal table.
- Table Category
The table category defines how an internal table is administered and how its individual rows can be accessed. There are three table categories:
- Standard tables are administered internally using a primary table index. If required, this primary table index can be implemented using a logical index. The table can be accessed using either a table index or a table key. The primary key of a standard table is always non-unique. The response time for accessing the table using the primary key is proportional to the number of entries in the table. You can define secondary table keys to make key access to standard tables more efficient.
- Sorted tables are also administered internally using a
primary table index. They are always sorted according to the
primary table key.
The sort order is in ascending order by size and returns the same result as the
SORTstatement with no additions. The table can be accessed using either a table index or a table key. The primary key of a sorted table can be either unique or non-unique. The response time for accessing the table using the primary key is logarithmically proportional to the number of table entries, since a binary search is used.
- Hashed tables are administered internally using a hash algorithm. Hashed tables can be accessed using a table key or a secondary table index. The primary key of hashed tables is always unique. The response time for primary key access is constant and independent of the number of entries in the table.
- Table key
A table key is used to identify rows in a table (see below). There are two possible key types for internal tables, primary keys and optional secondary keys. Every internal table has a primary key, which is either the standard key or a key you define yourself. Depending on the table category, the primary key is unique or non-unique. A secondary key is either a sorted key, which can be unique or non-unique, or a unique hash key. If keys are unique, a row with a specific content in the key fields can exist only once in the internal table. A table key can consist of components of the row type or of the entire row ( pseudo component table_line), if they are not internal tables or do not contain internal tables. When you define the table key, the order of the key fields is significant.
Unlike all other data types, a table type defined in ABAP Dictionary or using
TYPES does not have to be specified in full. You can omit either only the keys or the row type and the keys from the definition. This makes the type generic and it can be used only for
typings of field symbols and formal parameters. You can use the predefined
generic ABAP types ANY
INDEX TABLE for these purposes. The first type includes all table categories, the second type includes standard tables and sorted tables, known as
Like strings, internal tables are dynamic data objects. Their row type, table category, and table key are always specified in full, but the number of rows is variable and restricted only by the capacity of the system installation (see Maximum Size of Dynamic Data Objects).