Skip to content

ABAP Keyword Documentation →  ABAP − Reference →  Declarations →  Declaration Statements →  Data Types and Data Objects →  Declaring Data Types →  TYPES →  TYPES - TABLE OF 

TYPES - tabkind

Quick Reference

Other versions: 7.31 | 7.40 | 7.54

Syntax


... { {[STANDARD] TABLE} 
    | {SORTED TABLE}
    | {HASHED TABLE}
    | {ANY TABLE}
    | {INDEX TABLE} } ...

Extras

1. ... [STANDARD] TABLE

2. ... SORTED TABLE

3. ... HASHED TABLE

4. ... ANY TABLE
5. ... INDEX TABLE

Effect

Defines the table category of an internal table. Possible specifications:

  • Non-generic table categories
  • Generic table categories
  • ANY TABLE covers all table categories

The addition STANDARD is optional for standard tables.


Note

The additions of the statement TYPES listed above are language element additions for defining table categories. They are not to be confused with the generic ABAP types with the same name.

Programming Guideline

Use a suitable table category

Addition 1

[STANDARD] TABLE

Addition 2

SORTED TABLE

Addition 3

HASHED TABLE

Effect

The non-generic table categories specify the internal administration and primary access type for an internal table in ABAP programs:

  • Standard tables are managed internally in the system using a primary table index. New rows are either appended to the table or inserted at specific positions.
  • Like standard tables, sorted tables are also managed using a primary table index. The entries in this index are always sorted in ascending order by the primary table key. The sort order is in ascending order and returns the same result as the statement SORT with no additions. Sorting is based on the comparison rules for the data types of the key fields.
  • Hashed tables are managed by a hash algorithm. There is no primary table index. The entries are not ordered in the memory. The position of a row is calculated by specifying a key using a hash function.


Note

For non-generic table categories, the definition of the table key key determines whether the defined table type is generic.


Example

Declaration of two internal tables with the elementary row type string. The table words is a standard table with an empty key. The table sorted_words is a sorted table with the explicitly defined primary key table_line, in other words, the entire table row. When table words is assigned to table sorted_words, the rows are sorted in ascending order by their content.

DATA: words        TYPE STANDARD TABLE OF string 
                  WITH EMPTY KEY, 
      sorted_words TYPE SORTED TABLE OF string 
                  WITH NON-UNIQUE KEY table_line. 

SPLIT `This short text contains some short words` 
      AT ` ` INTO TABLE words. 
cl_demo_output=>write( words ). 

sorted_words = words. 
cl_demo_output=>display( sorted_words ). 

Addition 4

ANY TABLE

Addition 5

INDEX TABLE

Effect

The generic table categories define a generic table type that can only be used for typing formal parameters and field symbols:

  • ANY TABLE covers all table categories
  • INDEX TABLE covers standard tables and sorted tables


Note

A generic table type cannot be used as a component of a structured type.


Example

Defines a generic table type index_table for index tables. In the method meth, an index access can be performed on the parameter para typed using this type. Only index tables can be passed to this parameter. If there is not at least one row in the internal table, the method is exited.

CLASS cls DEFINITION. 
  PUBLIC SECTION. 
    TYPES index_table TYPE INDEX TABLE OF scarr. 
    METHODS meth IMPORTING para TYPE index_table. 
ENDCLASS. 

CLASS cls IMPLEMENTATION. 
  METHOD meth. 
    IF NOT line_exists( para[ 1 ] ). 
      RETURN. 
    ENDIF. 
    ... 
  ENDMETHOD. 
ENDCLASS.