‎2009 Nov 19 5:30 AM
Hi,
My collect statement is not working. Kindly let me know what is the other way to add one filed in the loop.
thanks
Moderator message - Please ask a specific question - post locked
Edited by: Rob Burbank on Nov 19, 2009 9:24 AM
‎2009 Nov 19 6:35 AM
How you are using COLLECT ?
*Prerequisite for the use of this statement is that wa is compatible with the row type of itab and all components that are not part of the table key must have a numeric data type (i, p, f). *
‎2009 Nov 19 6:42 AM
HI,
Take F1 Help on Collect Key word.
The Left Hand side of the numeric field value should be identical.
for Ex
itab contains vbeln posnr quantity--> in this case collect will not work since same sale order but items change
itab contains vbeln quantity only then it works.
take temp itab and do it as explained above then converge.
so make your left hand fields uniform and remove other fields then you purpose will be solved
or you can use CONTROL BREAK statement like AT NEW and then use key word SUM which sums up all numeric fields.
for more info take F1 help on AT NEW key word
Cheerz
Ram
‎2009 Nov 19 6:53 AM
For the COLLECT statement to work, all the fields in the internal table that are not a part of the key should be of numeric type.
You can also use control level processing. AT NEW , AT FIRST AT LAST etc.
This link might help.
http://help.sap.com/saphelp_nw70/helpdata/EN/9f/db9f1f35c111d1829f0000e829fbfe/content.htm
‎2009 Nov 19 12:35 PM
Same thing i faced few days ago --. i have resolved this using following logic ... try this it will workout
CLEAR: wa_mkpf_mseg, w_werks, w_matnr, w_lgort, w_bwart.
LOOP AT t_mkpf_mseg INTO wa_mkpf_mseg.
IF wa_mkpf_mseg-werks EQ w_werks AND wa_mkpf_mseg-matnr EQ w_matnr AND wa_mkpf_mseg-lgort EQ w_lgort AND wa_mkpf_mseg-bwart EQ w_bwart.
CLEAR: wa_p_coi.
READ TABLE t_p_coi INTO wa_p_coi WITH KEY werks = wa_mkpf_mseg-werks matnr = wa_mkpf_mseg-matnr lgort = wa_mkpf_mseg-lgort bwart = wa_mkpf_mseg-bwart.
IF sy-subrc = 0.
wa_p_coi-Avg Days = wa_p_coi-Avg Days + wa_mkpf_mseg-Avg Days.
MODIFY t_p_coi FROM wa_p_coi TRANSPORTING Avg Days .
CLEAR: wa_p_coi, wa_p_coi.
endif.
ELSE.
wa_p_coi-werks = wa_mkpf_mseg-werks.
wa_p_coi-matnr = wa_mkpf_mseg-matnr.
wa_p_coi-bwart = wa_mkpf_mseg-bwart.
wa_p_coi-lgort = wa_mkpf_mseg-lgort.
wa_p_coi-Avg Days = wa_mkpf_mseg-Avg Days .
APPEND wa_p_coi TO t_p_coi.
CLEAR: wa_p_coi.
ENDIF.
w_werks = wa_mkpf_mseg-werks.
w_matnr = wa_mkpf_mseg-matnr.
w_lgort = wa_mkpf_mseg-lgort.
w_bwart = wa_mkpf_mseg-bwart.
CLEAR: wa_mkpf_mseg.
ENDLOOP.