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

Summarizing entries of the Internal table

Former Member
0 Kudos

Hi All Experts!!

I have problem regarding summarizing of the entries of the internal table.I want the amount field of the entries be summed based on 3 fields of table rkst skst rkstar.It means that summation be carried out if the set of these 3 fields are same.If there is different set new entry will be created.

Here I want to summarize itab gt_yrepost2.

LOOP AT gt_yrepost2 INTO gwa_yrepost2.

sum_amount = sum_amount + gwa_yrepost2-amount

      • be summed for repeating sets of 3 fields*****

lwa_sum_yrepost2-amount = sum_amount.

lwa_sum_yrepost2-kokrs = gwa_yrepost2-kokrs.

lwa_sum_yrepost2-belnr = gwa_yrepost2-belnr.

lwa_sum_yrepost2-buzei = gwa_yrepost2-buzei.

lwa_sum_yrepost2-kstar = gwa_yrepost2-kstar.

lwa_sum_yrepost2-bukrs = gwa_yrepost2-bukrs.

lwa_sum_yrepost2-pbukrs = gwa_yrepost2-pbukrs.

lwa_sum_yrepost2-tcurr = gwa_yrepost2-tcurr.

lwa_sum_yrepost2-skst = gwa_yrepost2-skst."field1

lwa_sum_yrepost2-rkst = gwa_yrepost2-rkst."field2

lwa_sum_yrepost2-rkstar = gwa_yrepost2-rkstar."field3

lwa_sum_yrepost2-txt = gwa_yrepost2-txt.

APPEND lwa_sum_yrepost2 TO gt_sum_yrepost2.

It means that if there is change in set of key fields new entry will be created. Else the entries will be summed to a single entry.In this example gt_sum_yrepost2 contained the summed(summarized) entries.

The positive thing here is that if for one set of these fields the other values will be same.Hence other fields will take value of any of the repeating entries(with repeated set).

Please help in this regards..

Thanks in Advance....


Edited by: PRABHAS jha on Jan 25, 2008 4:34 PM


Former Member
0 Kudos

Hi Prabhas ,

You could use Collect statement instead of Append.