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
- SAP Samples: Internal Tables — table categories and keys
- ABAP Keyword Documentation: internal tables
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.
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
Write your solution, then check its structure.
One possible solution
TYPES: BEGIN OF ty_dispatch,
dispatch_id TYPE string,
status TYPE string,
END OF ty_dispatch.
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.
DATA(result) = 'STANDARD work list; HASHED dispatch lookup'.
WRITE result.out->write( result ).These are context-specific output examples. In your own program, use the result variable from your solution and the output mechanism available in that program.