Skip to Content

Cumulative sum in ALV report output

Mar 13 at 12:06 PM


avatar image

Hello all,

I given the fields of DMBTR and LIFNR in my ALV report and i got the number of vendors and Amounts in my output grid.So now how can i calculate the same vendor number with all the Amount added and give the total sum for that vendor and display only that one vendor number with all the total sum of amounts in output

Give me coding for that.

Thank you


10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Praveen Kumar Chitturi Mar 14 at 03:09 AM


If you have ABAP 7.4 then can use concept something like this.


Show 11 Share
10 |10000 characters needed characters left characters exceeded

Thank you praveen for giving answerreport1.txt.But i want logic according to my coding can you please give based on my coding and output.screenshot-24.png and my coding and output was like that. can you please give coding according to that.

report1.txt (2.1 kB)
screenshot-24.png (95.4 kB)

Hi Divya,

You can enhance the txt file logic as per your internal table right? Please let me know what exactly you have difficulty in implementing.



Praveen Kumar Chitturi

Actually,the coding what you sent was little bit confused to can you please explain clearly the coding according to what i send to you.

Thank you



data:t_dmbtr type mseg-dmbtr.

What i understood is
Lifnr Amount

L1 25

L2 30

L1 1

Cumulative Vendor Report

LIfnr Amount

L1 26

L2 30

If you need like above, Small operation you need to do.
You internal table like it_tab1

Sort it_tab1 by lifnr
now Create one more table like it_tab2 ,It_final Same files and structures.

Now move it_tab1 to it_tab2.

delete adjacent duplicates from it_tab1 comparing lifnr.

Now in the it_tab1 duplicate lifnr will be deleted.

Loop at it_tab1.

loop at it_tab2 where lifnr eq it-tab1-lfirn.
t_dmbtr = t_dmbtr + it_tab2-dmbtr .

it_final-lifnr = it_tab1-lifnr.
it_final-dmbtr = t_dmbtr.

append it_final.


Hope you understood, More than above there is no easy solution.


Thank you so much.It is useful to me.


What you sent the code was exactly done.But again when i calculate the amount it not getting the exacly same amount.Like

vendor(LIFNR) amount(DMBTR)

20 10

20 15

21 20

21 25

This is what i alrdy got.And when i use the code it got it what i want to be.but when i calculate the amount it just shown as

vendor(LIFNR) amount(DMBTR)

20 30

21 50

how to solve this issue?


Can i get your code.


Solved the issue.I declared another internal table and written the code for that properly.

Thank you

Show more comments

Hi Divya,

I recommend you to copy that code in a test program and debug . Then you will come to know the functionality and logic. If your system is having abap 7.4 then that logic is much useful.




Thankyou for your support.

Simone Milesi Mar 15 at 07:54 AM

It's a pretty basic question.

Apart Praveen Kumar Chitturi suggestion (which is the right way to do if you are at least on 7.40), even old ABAP offers you the solution with Control Level Staments.

Again, it's something pretty basic.

10 |10000 characters needed characters left characters exceeded