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.
cancel
Showing results for 
Search instead for 
Did you mean: 

Sum up

Former Member
0 Kudos

I have an internal table, which will store so no, material, quantity and the Debit/Credit Indicator, i would like to sum up the quantity which group by so no and material, how can i do that, because the Debit/Credit Indicator is H or S. Thanks!

5 REPLIES 5

Former Member
0 Kudos

Hi try this.

loop at it_tab into st_tab.

st_tab1 = st_tab.

if st_tab-indicator = 'H'.

st_tab-qua = st_tab-qua * (-1)

endif .

w_qua = w_qua + st_tab-qua.

at end of material.

move all the fields into new structure with required fields

and move w_qua into quantity field .

append that into internal table.

endloop.

Thanks,

Sarala.

Former Member
0 Kudos

Hi,

You can use the ON CHANGE OF for this one ..

LOOP AT ITAB.
ON CHANGE OF SO_NO  MATNR
 " Write the code here
ENDON

Regards

Sudheer

Former Member
0 Kudos

hi,

data: sum_h type menge,

sum_s type menge.

loop at itab into wa.

if wa-shkzg = H.

sum_h = wa_menge + sum_h.

else.

sum_s = wa_menge + sum_s.

endif.

sum_h = sum_h - sum_s.

clear sum_s.

endloop.

try this or loop it two times so that you can minus the sum of credit from debit.

Former Member
0 Kudos

Hi

see the rough logic.

sort itab by sno matnr.

loop at itab.

if itab-shkzg = 'H'.

itab-menge = itab-menge .

else.

itab-menge = itab-menge * -1.

endif.

at end of matnr.

read table itab index sy-tabix.

sum.

move the fields to other itab1.

append itab1.

endat.

clear itab1.

endloop.

Regards

anji

JozsefSzikszai
Active Contributor
0 Kudos

hi Portfolio,

I think the only thing you can do it that you LOOP AT the internal table and COLLECT each line to another internal table (in fact only so no, material and quantity) and multipliing the credit items with minus1 (before the COLLECT.

hope this helps

ec