ERPClimb logoERPClimb
Internal Tables
ABAP Developmentintermediate 7 min read

Internal Tables Part 3: Work Area vs Field Symbol vs Data Reference

Preview · a free account unlocks the full lesson

Key takeaway

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 sections

Visual overview

Internal Tables Part 3: Work Area vs Field Symbol vs Data Reference — learning sheetFlow: Run the three loops in the code example on SFLIGHT data → Compare runtimes with GET RUN TIME → Try a READ … ASSIGNING that fails and see the IS ASSIGNED check. Key ideas: WORK AREA (COPY); FIELD SYMBOL (POINTER-LIKE); DATA REFERENCE; WHICH ONE WHEN. Watch out: Check IS ASSIGNED / IS BOUND before use; never change key fields of sorted/hashed tables via <fs>.ERPClimb.com / ABAP / LESSON 3/10 / LEARNING SHEETInternal Tables Part 3: Work Area vs Field Symbol vs DataReference1 · HOW IT FLOWS1Run the three loops inthe code example onSFLIGHT data2Compare runtimes with GETRUN TIME3Try a READ … ASSIGNINGthat fails and see the ISASSIGNED check2 · KEY IDEAS EXPLAINEDWork Area (Copy)Safe and simple; the table changes only withMODIFY.Costs a copy per row — noticeable for wide rows orbig tables.Field Symbol (Pointer-Like)No copy, no MODIFY — fastest for changes.After a failed READ … ASSIGNING, the field symbolis not assigned → check IS ASSIGNED.Data ReferenceLike a field symbol, but a variable: can bestored, passed and put into tables of references.Check IS BOUND before dereferencing.Which One WhenRead-only, small rows → work area (clear andsimple).Changing rows in a loop → field symbol.3 · REMEMBER · WATCH OUTRememberINTO wa copies the row; changes need MODIFY to go back into the table.ASSIGNING <fs> points directly at the row; changes are immediate— no MODIFY, no copy.REFERENCE INTO lr stores a pointer you can keep (e.g. in anothertable).!Watch outCheck IS ASSIGNED / IS BOUND beforeuse; never change key fields ofsorted/hashed tables via <fs>.4 · IN A REAL PROJECTA pricing update program looped over 1.5 million condition records INTO a work area and used MODIFY for everyrow. The job ran for 40 minutes and used a lot of memory copying 120-field rows. Switching to LOOP … ASSIGNINGwith direct field changes removed both the copies and the MODIFY statements. Runtime dropped to under 10…Original ERPClimb learning sheet • Verify against your SAP release and edition

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.

Free account

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.