Hi vamshi,
Both Collect and AT END OF.... END AT, we can use for the above requirement.
Collect Statement:
LOOP AT IT_TABLE into WA_TABLE.
COLLECT WA_TABLE TO IT_FINAL.
ENDLOOP.
Control Break Statement (AT END OF... END AT):
If you are using Control break statement, before LOOP Statement, sort the table as shown below.
"Data Declarations
DATA: L_END TYPE I VALUE 0,
L_COUNT TYPE I VALUE 0.
"Sort the Internal Table
SORT IT_TABLE BY MATNR.
LOOP AT IT_TABLE INTO WA_TABLE.
L_COUNT = L_COUNT + WA_TABLE-VALUE.
AT END OF MATNR.
L_END = 1.
ENDAT.
IF L_END = 1.
MOVE CORRESPONDING WA_TABLE to WA_FINAL.
"Assign Count value
WA_FINAL-TOTAL = L_COUNT.
"Append the value to Internal Table
APPEND WA_FINAL TO IT_FINAL.
"Clear WA & Count
CLEAR: WA_FINAL,
L_COUNT,
L_END.
ENDIF.
ENDLOOP.
Regards
Rajkumar Narasimman