You can use the below code. I checked and got the output as per your requirement.
read table itab into wa index 1.
loop at itab into wa1 from 2.
if wa1 <> wa.
append wa to it_final.
else.
wa-quantity = wa-quantity + wa-quantity.
wa-rate = wa-rate + wa-rate. "Probably rate will be constant If required do it
append wa to it_final.
endif.
wa = wa1.
endloop.
Thanks,
Venkadesh