Appearance
Lesson 3 Companion — Types, Structures & Table Operations
1. Why explicit table keys matter
Modern ABAP makes table keys part of the type. The key influences uniqueness, ordering, and lookup strategy.
text
standard → index-first general collection
sorted → sorted key administration
hashed → hash-key administration2. WITH EMPTY KEY
For standard tables where no semantic primary key is intended, explicit WITH EMPTY KEY is clearer than relying on an implicit standard key.
3. Key reads do not automatically make a standard table fast
This syntax:
abap
products[ id = 'P1' ]can still be a linear search if the table has no optimized key for id.
The expression syntax and the table's technical access characteristics are separate concerns.
4. Field symbols for in-place modification
abap
LOOP AT products ASSIGNING FIELD-SYMBOL(<product>).binds the field symbol to the actual line. INTO DATA(product) creates a work-area copy.
5. In-memory CRUD terminology
It is fine to use CRUD as an analogy, but students should be able to say:
We changed an internal table, not persistent database data.
That distinction is critical before SQL.
6. Reference model
abap
TYPES:
BEGIN OF ty_product,
id TYPE c LENGTH 6,
name TYPE string,
category TYPE c LENGTH 10,
price TYPE decfloat34,
END OF ty_product,
tt_products TYPE HASHED TABLE OF ty_product
WITH UNIQUE KEY id.
DATA(products) = VALUE tt_products(
( id = 'P00001' name = 'Keyboard' category = 'IT' price = '49.90' )
( id = 'P00002' name = 'Mouse' category = 'IT' price = '19.95' )
).
IF line_exists( products[ id = 'P00002' ] ).
DATA(mouse) = products[ id = 'P00002' ].
ENDIF.7. Missing table-expression rows
A direct table expression can raise CX_SY_ITAB_LINE_NOT_FOUND. The caller should only assume success when the program contract guarantees the row exists.