Internal Tables Part 3: Work Area vs Field Symbol vs Data Reference
Preview · a free account unlocks the full lesson
Understand the three ways to access table rows — copying into a work area, pointing with a field symbol (ASSIGNING), or referencing with REFERENCE INTO — and when each is correct and fast.
In this lessonShow sectionsHide sections
Visual overview
Explanation
Parts 1 and 2 of this series read rows into work areas; now that you're changing data and working with large tables, the access technique you choose starts to matter a lot.
Reading into a work area copies the row. For example, LOOP AT gt_flights INTO gs_flight, then gs_flight-price = gs_flight-price * '1.1', and finally MODIFY gt_flights FROM gs_flight (which writes back using the index of the current loop row) inside the ENDLOOP. This is safe and simple, and the table only changes when you call MODIFY, but it costs a copy per row, which becomes noticeable for wide rows or big tables.
A field symbol behaves like a pointer. You declare FIELD-SYMBOLS <ls_flight> TYPE ty_flight, then LOOP AT gt_flights ASSIGNING <ls_flight>, and a statement like <ls_flight>-price = <ls_flight>-price * '1.1' changes the table row directly. There's no copy and no MODIFY needed, making this the fastest option for changes.
If a READ … ASSIGNING fails, the field symbol ends up unassigned, so you must check IS ASSIGNED before using it, and you must never modify the key fields of a sorted or hashed table through a field symbol, since that causes a runtime error.
Create a free account to keep reading
You have read the opening of this lesson. A free ERPClimb account unlocks the rest of it, every other lesson and topic, and your learning history, so you can pick up exactly where you stopped. No card needed.
- Full explanation
- Code example
- Real project scenario
- Common mistakes
- Best practices
- Interview angle
One tap with Google works too. Every topic keeps its first lesson open to everyone.
Keep exploring
Check before use: lesson examples are educational, not a guarantee of correctness for your SAP edition or release. Sample code has not been executed on your SAP system. Confirm API availability, syntax, authorizations and business impact in an approved development or test environment.