ABAP Keyword Documentation → ABAP − Release-Specific Changes → Changes in Releases 4.0 and 4.5
Internal Tables - Key Tables in Release 4.0
The following features of internal tables have been considerably improved in Release 4.0:
- Performance improvements, particularly for large tables. This has been achieved by introducing
hashed tables, whose access time is largely constant, that is, independent of the number of table entries.
- Introduction of sorted tables. This has removed the need for complex program code, whose tasks are now performed in the kernel.
- Support for generic programming by introducing generic table types.
The term default key has
been extended to include a user-definable key. In addition to the previous form of internal table (standard tables), SAP has introduced new table types for
sorted and hashed tables.
The key of these tables is an integral part of the type definition. For this reason, tables with these types are also generically known as key tables. For further information, see
internal tables.
Other versions: 7.31 | 7.40 | 7.54
New table types STANDARD TABLE, SORTED TABLE, and HASHED TABLE
standard tablesSorted tables
Generic table types INDEX TABLE and ANY TABLE
To allow generic programming, there is a Hierarchy
based on the basic internal table types listed above. The generic type INDEX TABLE
includes standard and sorted tables. The type ANY TABLE
can be used for any table.
Furthermore, you can define further generic types by omitting the line type, key, or uniqueness
attribute of a table (see TYPES
). This enables you to define the types of parameters in generic
procedures.
Typing procedure parameters
Since the old internal table type corresponds to the new standard table, you can only pass standard
tables to a TABLES
parameter. You can pass the new tables types to
FORM
and FUNCTION
parameters using the USING
or CHANGING
, and
IMPORTING, EXPORTING
, and CHANGING
additions.
New table operations
Entries in key tables are located using their key. This means that it must also be possible to add,
modify, and delete table entries using the appropriate table key. The following new table operations have therefore been introduced:
INSERT
... INTO TABLE ...
MODIFY
TABLE ...
READ
TABLE ... [FROM ...|WITH TABLE KEY ...]
DELETE
TABLE ... [FROM ...|WITH TABLE KEY ...]
The new operations are valid for all table types and are, in this respect, generic (for details of the
semantics, refer to the corresponding keyword documentation). In each of the statements, you can specify the key using a work area, either explicit or implicit (table with
header line). The key values
are then taken from the work area. In the READ
and DELETE
statements, you can also specify the key explicitly in the form:
... WITH TABLE KEY k1 = v1 ... kn = vn
Unlike the previous form of the READ
statement -
"WITH KEY k1 = v1 ... kn = vn
" - the new form must specify the key fully. This is tested within the syntax check.
The syntax of the new operations has been modeled as far as possible on the existing statements for reading, inserting, modifying and deleting table entries. Note the following rules of thumb:
- In the new operations, the word
TABLE
comes directly before the table name itself
- Use the addition
WITH TABLE KEY
to specify the key explicitly
Integration of the new table types
The new table types can be used both in the new table operations listed above and in existing ABAP statements. Thus, you can also use the following statements with key tables: