Aggregating rows in SAP ABAP with the same name

You can use the COLLECT keyword or some aggregate functions to achieve the result. You should define some datatype to match the scenario.

TYPES: BEGIN OFt_my_type,
   key_aTYPE foo,
   key_bTYPE foo,
   nokey_cTYPE foo,
   nokey_dTYPE foo,
END OFt_my_type,
tt_my_type_list TYPE STANDARD TABLE OF t_my_type WITH DEFAULT KEY,
tt_my_type_hash TYPE HASHED TABLE OF t_my_type WITH KEY key_a key_b.
DATA: lt_resultTYPE tt_my_type_list,
   lt_sums TYPE tt_my_type_hash.
FIELD-SYMBOLS:<ls_result> TYPE t_my_type.
LOOP AT lt_result ASSIGNING <ls_result>.
   COLLECT<ls_result> INTO lt_sums.