Skip to main content

Filter Records by Condition

BeginnerInternal Tables⏱ 10 min

Task

You are given an internal table containing material number, plant, and quantity. Filter and process only the records where WERKS matches a given plant.

  • Use LOOP with WHERE condition
  • Process filtered records only
  • No database access required

Write Your ABAP Code

ABAP Editor
Loading...
📥 Sample Input & Output
MATNR   WERKS   MENGE A100    1000    10 A200    2000    5 A300    1000    7 Input Plant: 1000 Filtered Records: A100, A300
💡 Hint

Use LOOP AT it_data INTO DATA(ls_row) WHERE werks = lv_werks

✅ View Reference Solution
LOOP AT it_data INTO DATA(ls_row) WHERE werks = lv_werks. " Process ls_row ENDLOOP.