01-30-2008 7:57 PM
Hey folks,
i have records and i have to sum them up modify the table by inserting the sum value without using collect. how can i do it ..
for example
table itab contains
1
2
3
4
5
i have to modify this table and insert the sum value like itab shud contain 15 only but without using the collect statemnt . could somebody write me a sample code for this.
Regards
Rock
Edited by: Alvaro Tejada Galindo on Jan 30, 2008 3:13 PM
01-30-2008 8:08 PM
Are you saying that you want to find the sum and then replace the individual entries with just a sum entry? If that is the case, you could use something like this:
LOOP AT itab INTO wa_itab.
ADD wa_itab-field1 to field1_sum.
ENDLOOP.
CLEAR itab.
wa_itab-field1 = field1_sum.
APPEND wa_itab TO itab.
If you just want to add a record for the sum (without deleting the others), just remove the CLEAR statement. I hope this helps.
- April King
01-30-2008 8:08 PM
Are you saying that you want to find the sum and then replace the individual entries with just a sum entry? If that is the case, you could use something like this:
LOOP AT itab INTO wa_itab.
ADD wa_itab-field1 to field1_sum.
ENDLOOP.
CLEAR itab.
wa_itab-field1 = field1_sum.
APPEND wa_itab TO itab.
If you just want to add a record for the sum (without deleting the others), just remove the CLEAR statement. I hope this helps.
- April King