Skip to main content

Using COLLECT for Aggregation

IntermediateInternal Tables⏱ 15 min

Task

Aggregate quantities by material number using the COLLECT statement.

Write Your ABAP Code

ABAP Editor
Loading...
📥 Sample Input & Output
A100  10
A100  5
A200  7

Output:
A100  15
A200  7
💡 Hint

COLLECT automatically sums numeric fields with identical keys.

✅ View Reference Solution
LOOP AT it_sales INTO DATA(ls_sale).
  COLLECT ls_sale INTO it_sales.
ENDLOOP.