ABAP Internal Tables: Standard vs Sorted vs Hashed
ABAP has three concrete internal-table categories: standard, sorted, and hashed. Standard tables favor index access and cheap appends, sorted tables maintain key order and support logarithmic key access, and hashed tables use a unique hash key for key-based access without a primary index. The right choice depends on how the table is filled, read, changed, and iterated.
Practitioner guide to ABAP Internal Tables: Standard vs Sorted vs Hashed: what it means, when to use it, how it fits SAP architecture, a concrete support/development example, decision rules, production pitfalls, S/4HANA implications, ownership, and related technical objects.
Reviewed by an ERPClimb SAP consultant on 20 Sept 2026· 793 words
What it is
An internal table is ABAP's in-memory collection type, but its table category determines how rows are organized and how key access behaves. A standard table has a primary index and a non-unique primary key; a sorted table also has an index but keeps rows ordered by its primary key; a hashed table has no primary table index and requires a unique hash key. This is not merely syntax style: the category affects insertion cost, uniqueness rules, index access, range processing, and lookup behavior. SAP's current ABAP documentation also allows secondary sorted or hashed keys on internal tables, so the design is no longer limited to one access path.
When to use it
Choose the table category from the dominant access pattern, not from habit. Use a standard table when sequential processing or index access dominates and key lookups are limited or can be supported by a secondary key. Use a sorted table when you need ordered iteration, partial-key/range access, or frequent key searches while still retaining index behavior. Use a hashed table when almost every access is by the complete unique key and order is irrelevant. For very small tables, the simplest declaration is often sufficient; for large hot tables, the access pattern matters.
How it fits the stack
Internal tables sit between database retrieval and application logic. Open SQL should reduce the database result set first; internal tables then support grouping, enrichment, validation, mapping, and output preparation in ABAP memory. Table keys interact with READ TABLE, table expressions, LOOP ... USING KEY, FILTER, INSERT, MODIFY, DELETE, and constructor expressions. They also affect performance discussions about nested loops, binary search, and secondary keys. Internal-table design therefore belongs in the same review as database access rather than being treated as a purely local coding detail.
A worked example
A pricing utility loads 200,000 condition rows and repeatedly looks up one row by a complete business key. Keeping them in a standard table and issuing READ TABLE WITH KEY without an optimized key forces repeated linear searches. Replacing the collection with a hashed table keyed by the exact lookup fields makes the intent explicit and gives efficient key access. A different report that must print the same rows in key order and frequently process key ranges may be better served by a sorted table. The correct category changes with the read pattern, even when the row structure is identical.
How to choose
- Need numeric index access or mostly append/loop processing: start with a standard table.
- Need permanently sorted order or range/partial-key processing: prefer a sorted table.
- Need frequent full-key lookup with guaranteed uniqueness and no index access: prefer a hashed table.
- Need two very different access paths on the same data: consider a secondary sorted or hashed key before duplicating the table.
- Measure large hot-path tables; do not optimize a ten-row table as if it contains a million rows.
Common pitfalls
- Declaring every internal table as STANDARD TABLE and later adding BINARY SEARCH inconsistently.
- Using BINARY SEARCH on a standard table that was not sorted by the exact compatible key order.
- Choosing a hashed table and then trying to use index operations that do not exist for its primary organization.
- Defining wide or unnecessary secondary keys that increase memory and update cost without enough read benefit.
- Assuming database-table key rules and internal-table key rules are identical.
ECC, S/4HANA and clean core
The standard/sorted/hashed distinction is current ABAP behavior in S/4HANA and ABAP Cloud as well as classic systems. HANA does not make poor in-memory ABAP access patterns free. Modern ABAP adds table expressions and secondary keys, but those features still depend on the declared table category and key. For cloud-ready code, the same language semantics apply; the main difference is which application APIs can supply the data.
Whose problem this is
ABAP developers own the table category and key design. Performance reviewers should challenge large frequently accessed tables when the declared category does not match the lookup pattern. Functional teams normally do not own this decision, although they define the uniqueness and grouping rules represented by the key.
Related SAP objects
Reviewed pages this object connects to in the ERPClimb knowledge graph.
Source: ERPClimb — https://erpclimb.com/sap-technical-topics/abap-internal-tables-standard-sorted-hashedERPClimb is an independent platform and is not affiliated with SAP SE. Reference pages are written and reviewed by SAP consultants for learning and troubleshooting.