Skip to Content
author's profile photo Former Member
Former Member

Sum value without using collect

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jan 30, 2008 at 08: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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.