Skip to content

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

TYPES - TABLE OF

Quick Reference

Other versions: 7.31 | 7.40 | 7.54

Syntax


TYPES table_type { {TYPE
tabkind OF [REF TO] type} 
                 | {LIKE tabkind OF dobj} }
                 [tabkeys]
                 [INITIAL SIZE n].

Addition

... INITIAL SIZE n

Effect

This statement defines a table type table_type with a specific row type, a table category tabkind, and table keys tabkeys.

The row type is determined by entering the data type type after TYPE and data type dobj after LIKE:

  • type can be a non-generic data type from ABAP Dictionary, a non-generic public data type of a public data type of a global class, a non-generic data type local to a program, or any ABAP type from the tables of built-in ABAP types. The generic ABAP types c, n, p, and x are extended implicitly to the standard length without decimal places from the tables of built-in ABAP types.

    If the addition REF TO is specified before type or dobj, the row type is a reference type. The information specified in the section reference types can then be specified for type and dobj.
  • The same applies to dobj as to TYPES ... LIKE.


Example

Defines a non-generic sorted table type. The row type corresponds to the structure of the database table SPFLI. Two key fields are defined for the primary table key.

TYPES spfli_sort TYPE SORTED TABLE OF spfli 
      WITH UNIQUE KEY carrid connid. 

Addition

... INITIAL SIZE n

Effect

The optional addition INITIAL SIZE has two meanings:

  • Note for the internal memory management of internal tables

    Internal tables are stored in the memory block by block. After the optional addition INITIAL SIZE, it is possible to specify a number of rows n directly as a positive number without sign or as a numeric constant to notify the system of the size of the initial block in the memory (reserved by the system for an internal table of the table type). By default, and if n is specified as 0, the system allocates a suitable initial memory area automatically.

    If the initial memory area is not large enough, further blocks are created using a duplicate strategy until a maximum size is reached. After this, all blocks are created with a constant size between 8 and 16 KB.

    If the value of n causes the initial blocks to become too big, the size of the initial memory area is also defined by the system.
  • Size of Rankings

    To create a ranking in the internal table using the addition SORTED BY of the statement APPEND, a value greater than 0 must be specified after INITIAL SIZE. This determines the size of the ranking.

Programming Guideline

Modify the initial memory requirements only for nested tables


Notes

  • You are advised to specify the initial memory requirements only when the number of entries in the table has already been specified and the initial main memory requirement has an adequate value. This can be especially important for internal tables that are components of table types and only contain a few rows.
  • Instead of APPEND SORTED BY, the statement SORT must be used so that the addition INITIAL SIZE is no longer required here.

Continue

TYPES - tabkind

TYPES - tabkeys

Internal Tables, Nested Tables