2008 Nov 21 4:28 PM
HI SDN,
I am bringing the data into internal table like this
TYPES: BEGIN OF ty_EKAB,
i_CONTRACT LIKE /BIC/AZPUR_OAP00-CONTRACT,
i_CONT_ITEM LIKE /BIC/AZPUR_OAP00-CONT_ITEM,
i_ZNET_VAL LIKE /BIC/AZPUR_OAP00-/BIC/ZNET_VAL,
i_ZORDR_QTY LIKE /BIC/AZPUR_OAP00-/BIC/ZORDR_QTY,
END OF ty_EKAB.
DATA: IT_EKAB TYPE SORTED TABLE OF ty_EKAB
WITH NON-UNIQUE KEY i_CONTRACT i_CONT_ITEM ,
WA_EKAB TYPE ty_EKAB.
SELECT CONTRACT CONT_ITEM /BIC/ZNET_VAL /BIC/ZORDR_QTY INTO
TABLE IT_EKAB FROM /BIC/AZPUR_OAP00.
and Data looks like this
4600000000 00040 54,635.00 1.000
4600000000 00040 40,365.00 1.000
4600000002 00010 0.00 0.000
4600000002 00010 91,200.00 1.000
4600000002 00010 31,554.00 1.000
My question : Is there any statement on Internal table which aggregate the values with same CONTRACT CONT_ITEM .
Thanks
2008 Nov 21 4:32 PM
some ways to perform
- Loop at the internal table and use [COLLECT|https://www.sdn.sap.com/irj/scn/advancedsearch?query=collect&cat=sdn_all] statement into another table of same structure (also look help.sap.com at [Appending Summarized Lines|http://help.sap.com/erp2005_ehp_03/helpdata/EN/fc/eb36d5358411d1829f0000e829fbfe/frameset.htm])
- Sort the internal table and APPEND to another table using [SUM in a AT END OF|https://www.sdn.sap.com/irj/scn/advancedsearch?cat=sdn_all&query=sumATEND+OF&adv=false&sortby=cm_rnd_rankvalue] block (also look help.sap.com at [Processing Table Entries in Loops|http://help.sap.com/erp2005_ehp_03/helpdata/EN/fc/eb381a358411d1829f0000e829fbfe/frameset.htm])
- use a GROUP BY clause in your [SELECT INTO TABLE|https://www.sdn.sap.com/irj/scn/advancedsearch?cat=sdn_all&query=selectINTOTABLEGROUPBY&adv=false&sortby=cm_rnd_rankvalue] (also look help.sap.com at [Reading Data|http://help.sap.com/erp2005_ehp_03/helpdata/EN/fc/eb3983358411d1829f0000e829fbfe/frameset.htm])
Regards
2008 Nov 21 4:36 PM
Hi
Yes, you can do it using COLLECT statement, like
DATA: IT_EKAB TYPE SORTED TABLE OF ty_EKAB
WITH NON-UNIQUE KEY i_CONTRACT i_CONT_ITEM ,
data: i_sum type sorted table of ty_ekab with key i_contract i_cont_item,
w_ekab type ty_ekab.
loop at it_ekab into w_ekab.
collect w_ekab into i_sum.
clear w_ekab.
endloop.
The sum result is in the table i_sum.