11-02-2021 5:56 AM
Hi ABAPER's,
i have to add quantity field( BDMNG) value against BAUGR and BDTER field value ,
how to use collect statement in new ABAP 7.5 to add quantity values?
Please share the solution.
Thanks
TYPES: BEGIN OF TY_DATA,
MATKL TYPE -MARA-MATKL,
MATNR TYPE MARA-MATNR, "RESB-BAUGR
Quantity TYPE RESB-BDMNG,
MONTH TYPE CHAR2, "RESB-BDTER+4(2)
YEAR TYPE CHAR4, "RESB-BDTER+0(4)
END OF TY_DATA,
TT_DATA TYPE HASHED TABLE OF TY_DATA
WITH UNIQUE KEY MATKL MATNR,<br>
11-02-2021 6:14 AM
Here is how the COLLECT statement works in new ABAP, same as in old ABAP.
https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abapcollect.htm.
A modern alternative might be REDUCE
11-02-2021 6:48 AM
it will not work simply, because he has the field MATKL in the table. As it does not specify this column for the collect, the logic could not work. He needs to create another table from this one.
11-02-2021 7:55 AM
Hi,
I am updating entries to final table from two different tables MARA and RESB , in that scenario the first collect example will not work.
any other solution?
Thanks
11-02-2021 8:07 AM
You should provide your code, if it is a SELECT statement you could do a SUM, GROUP BY ... or better a CDS