2022 Jul 04 11:20 AM
Hi All,
I have an Internal table with fields that I want to add and merge. For ex:
plant bomID matnr idnrk menge vornr plnnr
1100 1028-02 111222 11122205 100 31 5555-1
1100 1028-02 111222 11122205 200 33 5555-2
1100 1028-01 111222 11122203 200 34 5555-2
1100 1028-01 111222 11122203 200 33 5555-2
1100 1028-02 111222 11122201 100 33 5555-2
Now I want to add the MENGE field(it is type p) according to idnrk and result should be
plant bomID matnr idnrk menge vornr plnnr
1100 1028-02 111222 11122205 300 31 5555-1
1100 1028-02 111222 11122203 400 33 5555-2
1100 1028-01 111222 11122201 100 33 5555-2
I am using collect statement but it is not working. Kindly suggest
2022 Jul 04 11:41 AM
Why do you say it didn't work?
what is the result ? what is the code used ?
2022 Jul 04 12:21 PM
COLLECT statement "adds and merges" very well in the conditions explained in the ABAP documentation.
2022 Jul 04 1:21 PM
1. Collect statement could not collect the data according to a specific field( Ex: In you case menge could not be collected for IDNRK only)
2. In your structure collect statement collect the menge according to below highlighted fields.
plant bomID matnr idnrk menge vornr plnnr
Hence collect statement won't fulfill your requirement
3. Solution :Try to use the structure with less no.of fields if possible and use collect. Or use loop statement and add menge.
2022 Jul 06 7:08 AM
The Collect statement is just adding up but line items are not merging. As stated by Rama Chittimadi, Thanks for the inputs. I am using loop statement.
2022 Jul 06 7:14 AM
Hi Preetham
Collect statement is like a Group by Clause in SQL.
So for each combination of
Plant + BomID + Material + Maerial(idnrk) + vornr + plnnr == sum(menge).
So if you want on any specific one , then you need to handle other also not chaning.