03-13-2018 12:06 PM
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
03-14-2018 3:09 AM
Hello,
If you have ABAP 7.4 then can use concept something like this.
03-14-2018 3:09 AM
Hello,
If you have ABAP 7.4 then can use concept something like this.
03-14-2018 6:14 AM
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.
03-14-2018 6:40 AM
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.
03-14-2018 7:32 AM
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
03-14-2018 10:12 AM
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.
03-14-2018 10:32 PM
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.
03-15-2018 5:47 AM
03-15-2018 5:49 AM
03-15-2018 11:23 AM
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?
03-15-2018 11:52 AM
03-15-2018 12:09 PM
Solved the issue.I declared another internal table and written the code for that properly.
Thank you
03-15-2018 12:10 PM
03-15-2018 7:54 AM
It's a pretty basic question.
Apart praveen.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.
https://wiki.scn.sap.com/wiki/display/ABAP/Control+Level+Statements+in+ABAP
Again, it's something pretty basic.