Skip to main content

Sum of Values by Plant

BeginnerInternal Tables⏱ 10 min

Task

You are given an internal table containing material number, plant, and quantity. Calculate the total quantity for a given plant.

Write Your ABAP Code

ABAP Editor
Loading...
📥 Sample Input & Output
MATNR   WERKS   MENGE
A100    1000    10
A200    1000    5
A300    2000    7

Input Plant: 1000
Output: 15
💡 Hint

Loop through the internal table and add MENGE when WERKS matches.

✅ View Reference Solution
LOOP AT it_data INTO DATA(ls_row)
     WHERE werks = lv_werks.
  lv_total = lv_total + ls_row-menge.
ENDLOOP.