Pick the table for the work, not by habit

An in-memory work list may be processed from first row to last, while another collection is mainly searched by a unique dispatch ID. ABAP offers different internal-table categories because those jobs have different access needs.

Match the category to the access

TYPES ty_worklist TYPE STANDARD TABLE OF ty_dispatch WITH EMPTY KEY.
TYPES ty_by_id TYPE HASHED TABLE OF ty_dispatch WITH UNIQUE KEY dispatch_id.
  • STANDARD keeps insertion order and supports index access; primary-key reads can require scanning.
  • SORTED keeps rows ordered by its key and supports index and efficient key access.
  • HASHED is optimized for complete unique-key access and has no index access.

Hashed and sorted keys constrain their key components: key fields cannot be changed in a way that would invalidate the table’s organization. Hashed tables also require a unique key. No category is universally fastest; insertion, memory, key maintenance, and the actual lookup pattern all matter.

Start with STANDARD TABLE ... WITH EMPTY KEY when you need sequential processing and no meaningful key. Choose sorted or hashed only when the access requirements justify it. Check the target release for syntax and supported table features.

Sources

Developer practice · ABAP

Practice: select a table type for each access pattern

Declare a sequential work list with an empty primary key and a keyed lookup table with a unique dispatch ID.

Choose your ABAP environment

This choice changes the output pattern checked here: WRITE belongs in a classic executable report, while out->write( ) uses the supplied output reference in an ABAP Cloud class-run method. It does not switch the language version of the other code; check release and API availability in your target system.

Complete the task and include the output statement shown for your selected environment. Variable names can differ if you use them consistently. This browser checker checks structure only; it does not compile or run ABAP.

0 required structures detected · 0 checks