Skip to Content
-1

Cumulative sum in ALV report output

Mar 13 at 12:06 PM

75

avatar image
Former Member

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

divya

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

2 Answers

avatar image
Former Member Mar 14 at 03:09 AM
3

Hello,

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

sample-logic-for-cumulative-amounts.txt


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

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)
0
Former Member

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.

Thanks,

Praveen.

0
Former Member
Former Member

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

Thank you

0

Hi,

data:t_dmbtr type mseg-dmbtr.

What i understood is
Report
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 .
endloop

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

append it_final.
clear:it_final,t_dmbtr.

endloop.
endloop.

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

0
Former Member
Kali Charan

Thank you so much.It is useful to me.

0
Former Member
Kali Charan

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?

0

Can i get your code.

0
Former Member
Kali Charan

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

Thank you

0
Show more comments
Former Member
Former Member

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.

Thanks,

Praveen.

1
Former Member

Thankyou for your support.

0
Simone Milesi Mar 15 at 07:54 AM
-1

It's a pretty basic question.

Apart Former Member 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.

https://wiki.scn.sap.com/wiki/display/ABAP/Control+Level+Statements+in+ABAP

Again, it's something pretty basic.

Share
10 |10000 characters needed characters left characters exceeded