06-02-2006 10:41 AM
Hi,
I have one internal table with NETWR value with other fields.
now i have netwr values as 10,20,30,40.
Then i should sum up NETWR value for internal table on a single hit.
Can anybody have the solution.
Right now i am looping at that I.Table and calculating sum of all NETWR's.
Any other solution!
Thanks,
Prasad.
06-02-2006 10:43 AM
select netwr into lv_netwr from vbrk
where cond....
gv_netwr = gv_netwr + lv_netwr
endselect.
write: gv_netwr.
06-02-2006 10:45 AM
06-02-2006 10:45 AM
If you have values in different fields of the table, then summing up inside the loop is the solution.
Regards,
Ravi
06-02-2006 10:48 AM
06-02-2006 10:49 AM
Hi,
i think loop is the only solution.
to optimize u can use sum in a loop
loop at itab.
at end of <Field name>
sum.
append value in some other table.
endat.
endloop.
for that field_name should be first field and sorted.
mark Helpfull Answers
Regards
06-02-2006 10:59 AM
Hi,
If you want to sum up the NETWR based on some condition then you can write the code like this.
Loop at Itab where <condition>
COLLECT itab INTO i_final.
Endloop.
or
Loop at Itab.
if <condition>
COLLECT itab INTO i_final.
Endif.
Endloop.
OR
If you want to sum up these NETWR based on Document number for example PO# then you need to write like this.
Sort itab[] by order_number.
loop at itab.
at new order_number.
loop at itab where order_number = itab-order_number.
Collect itab into i_final.
endloop.
endat.
endloop.
Cheers,
Bujji.