SAP NetWeaver AS ABAP Release 740, ©Copyright 2014 SAP AG. All rights reserved.
ABAP Keyword Documentation → ABAP − Release-Specific Changes → Changes in Releases 4.0 and 4.5 →
Internal Tables and Key Tables in Release 4.0
The following features of internal tables have been improved considerably in Release 4.0:
The term standard key
has been extended to include a user-definable key. In addition to the previous form of internal tables (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.
New table types: STANDARD TABLE, SORTED TABLE, and HASHED TABLE
Internal tables in their old form are now known as standard tables. The old
type TABLE has now been replaced by STANDARD TABLE.
The new types SORTED TABLE and HASHED TABLE have been introduced.
Sorted tables are always stored sorted by their table key in ascending order. The access time is logarithmically related to the number of table entries.
Hashed tables are
managed internally using a hash procedure. The access time to a single table entry is essentially constant, that is, the access time is independent of the number of entries.
This means that a complete table type is defined as follows:
1. Table category (STANDARD TABLE, SORTED TABLE, HASHED TABLE)
2. Row type
3. Key (the order is part of the type definition)
4. Uniqueness attribute (UNIQUE, NON-UNIQUE)
For further information about defining table types and objects, see the documentation for the
statements TYPES and DATA.
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, further generic types can be defined by omitting the row type, key, or uniqueness
attribute of a table (see TYPES). This enables the types of parameters to be defined in generic
procedures.
Typing procedure parameters
Since the old internal table type corresponds to the new standard table, only standard tables can be passed to a TABLES parameter. The new tables types can be passed to FORM and FUNCTION parameters using the additions USING or CHANGING or the additions IMPORTING, EXPORTING, and CHANGING.
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:
The new operations are valid for all table categories and are, in this respect, generic (for details
of the semantics, refer to the corresponding keyword documentation). In each of the statements, the key can be specified using a work area, either explicit or implicit (table with
header line). The key values
are then taken from the work area. In the statements READ and DELETE, the key can be specified 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 in full. 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:
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. This means that the following statements can also be used on key tables: