10-08-2007 1:51 PM
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!
10-08-2007 1:56 PM
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.
10-08-2007 1:56 PM
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
10-08-2007 1:58 PM
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.
10-08-2007 1:58 PM
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
10-08-2007 1:58 PM
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