Skip to Content
avatar image
-1
Former Member

Comibing Multipe Rows in to single ROW on basis of same fields Value.

Hi guys,

I have a requirement to Summarize the internal having mutliple rows into less no of rows having same fields value.

For example

G/L : Profitcenter : amount : net amount : difference

1000015899 271 500 450 50

2000015441 271 600 -450 -50

1000015899 271 500 450 150

2000015441 271 600 -450 -150

1000015899 272 500 450 200

2000015441 272 600 -450 -200

1000015899 272 500 450 300

2000015441 272 600 - 450 : -300

output be like this:

1000015899 271 500 450 200

2000015441 271 600 -450 : -200

1000015899 272 500 450 500

2000015441 272 600 -450 : -500.

i have only two g/l 1000015899, 2000015441 if g/l and profit center in rows are same then it will sum the difference field and make a single row.

Kindly suggest as I already applied a collect statement but unfortunatly it didn't work

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • May 18, 2017 at 09:23 PM

    Can you qualify 'didn't work'?

    The COLLECT statement was made to handle tasks like these.

    It's very straightforward - Please try again.

    Add comment
    10|10000 characters needed characters exceeded

    • I'm guessing COLLECT's fault was that it couldn't read the OP's mind and figure out that only the last number is to be summarized. Diana already answered kindly.

      And just to think Horst Keller's team put such effort into writing good ABAP documentation, sigh...

  • avatar image
    Former Member
    May 19, 2017 at 06:58 AM

    Hi David,

    Collect statement will work.

    COLLECT wa INTO itab.

    This statement inserts the content of a work area wa either as a single row in an internal table itab or adds the values of its numeric components to the corresponding values of existing rows with the same primary table key.

    Only the 'difference' field should be numeric.

    Add comment
    10|10000 characters needed characters exceeded