Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

alv-sum

Former Member
0 Likes
636

Hi Experts,

i have issue were in i need to show sum of the amount. like example...

for Custmer 100 there are vendor number 10,20,30,40,50. so for all this vendor numbers..

vendor----- amount

10----


100

20----


200

30----


300

40----


400

50-------500

so in the output i want it to be..

customer--


vendornumber--


amount

1000--


10--


1500

-


20---

-


30---

-


40---

-


50---

.hope u experts have undestood. so how can i add the it and show it in the output....

am forwarding my code also..

Corrects answers will be fully rewarded..

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
607

Hi,

For e.g consider your table as itab with colums customer, vendor, amount

now customer has the data with customer number 1000

10----


100

20----


200

30----


300

40----


400

50-------500

data sum_amount type p.

data last_vendor.

sort itab by customer ascending vendor descending.

loop at itab.

add itab-amount to sum_amount.

at end of vendor.

last_vendor = 'X'.

endat.

if last_vendor = space.

clear itab-amount.

modify itab.

else.

move sum_amount to itab-amount.

modify itab transporting amount.

clear sum_amount.

clear last_vendor.

endif.

endloop.

please reward points if usefull.

4 REPLIES 4
Read only

Former Member
0 Likes
607

hi sunita,

can u show me ur code so dat i can have idea what query u r using.

Read only

Former Member
0 Likes
608

Hi,

For e.g consider your table as itab with colums customer, vendor, amount

now customer has the data with customer number 1000

10----


100

20----


200

30----


300

40----


400

50-------500

data sum_amount type p.

data last_vendor.

sort itab by customer ascending vendor descending.

loop at itab.

add itab-amount to sum_amount.

at end of vendor.

last_vendor = 'X'.

endat.

if last_vendor = space.

clear itab-amount.

modify itab.

else.

move sum_amount to itab-amount.

modify itab transporting amount.

clear sum_amount.

clear last_vendor.

endif.

endloop.

please reward points if usefull.

Read only

Former Member
0 Likes
607

Hi Sunita,

In the field catalog that you have prepared, just check the field SUM for the amount field. It will add all the amounts for that particular customer and display the sum of amounts .

Read only

Former Member
0 Likes
607

Hi,

For ALV Sum try to use this :

wa_fieldcat-do_sum = 'X' while you are populating the field catalogue for that particular field.

Thanks.

Swati.