Skip to Content
-1

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

May 18, 2017 at 08:31 PM

109

avatar image
Former Member

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

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Paul Bakker May 18, 2017 at 09:23 PM
2

Can you qualify 'didn't work'?

The COLLECT statement was made to handle tasks like these.

It's very straightforward - Please try again.

Show 1 Share
10 |10000 characters needed characters left 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...

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

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.

Share
10 |10000 characters needed characters left characters exceeded