‎2022 Aug 10 10:54 AM
in my internal table the data's are like this .
5888 10 C 100
5888 10 C 30
5888 10 D 20
5888 20 D 50
5888 30 D 100
5888 30 D 100
5890 10 C 50
5890 10 C 50
5890 20 C 100
5890 20 D 50
5890 20 D 20
5890 40 C 100
5890 40 D 30
5892 20 C 20
5892 30 D 10
5892 30 D 10
5892 30 D 10
5892 40 D 10
5892 40 C 10
5892 40 C 10
5892 40 C 10
its needs to be like .
Doc number Doc item Balance
5888 10 110
5888 20 50
5888 30 -200
Sub Total -40
Doc number Doc item Balance
5890 10 100
5890 20 30
5890 40 -70
Sub Total 60
Doc number Doc item Balance
5892 20 20
5892 30 -30
5892 40 20
Sub Total 10
Grand Total -50
‎2022 Aug 10 12:22 PM
The answer will be different according to how you render the result. Is it ALV? Something else?
Or is it just homework? In that case, what is your problem with looping at the lines, doing the sum if same doc number and same doc item, doing the subtotal or the grand total?
‎2022 Aug 10 12:30 PM
You can use loop - endloop : Within that COLLECT statement.
‎2022 Aug 10 3:43 PM
Hi jeniljeff
Please find syntax below.make sure when you use control break statement, sort internal table by fields which are used with control break statement.sort it_tab ascending by filed_name1 field_name2.
Loop at it_tab into wa_tab.
at new field_name1(Doc_Number) field_name2(C,D..) .
write:/ Doc_number.
endat.
write: doc_item.
at end of field_name1(Doc_Number) field_name2(C,D..)
sum.
write: Balance.
total = total + balance.
endat.
endloop.
write:/ 'Grand Total is',total.