‎2005 Nov 14 6:36 PM
Hi,
i'm having trouble adding the quantity of fields that have the same MATNR and INVTY...Can anyone help me please!
here is my code:
SELECT MATNR LABST UMLME INSME EINME SPEME RETME LGORT
INTO TABLE T_MARD FROM MARD
FOR ALL ENTRIES IN IT_MATNR_TEMP
WHERE MATNR = IT_MATNR_TEMP-MATNR
AND WERKS = '0111'
AND LGORT IN LS_LGORT.
LOOP AT T_MARD.
IF T_MARD-LGORT = '0345'.
IT_MATNR_TEMP-INVTY = '02'.
L_MATNR_QUANT_02 = ( T_MARD-LABST + T_MARD-UMLME + T_MARD-INSME +
T_MARD-EINME + T_MARD-SPEME + T_MARD-RETME )
+ L_MATNR_QUANT_02.
MOVE L_MATNR_QUANT_02 TO IT_MATNR_TEMP-QUANT.
MOVE-CORRESPONDING IT_MATNR_TEMP TO IT_MATNR.
APPEND IT_MATNR.
ELSEIF T_MARD-LGORT = '0340'.
IT_MATNR_TEMP-INVTY = '04'.
L_MATNR_QUANT_04 = ( T_MARD-LABST + T_MARD-UMLME + T_MARD-INSME +
T_MARD-EINME + T_MARD-SPEME + T_MARD-RETME )
+ L_MATNR_QUANT_04.
MOVE L_MATNR_QUANT_04 TO IT_MATNR_TEMP-QUANT.
MOVE-CORRESPONDING IT_MATNR_TEMP TO IT_MATNR.
APPEND IT_MATNR.
ENDIF.
ENDLOOP.
‎2005 Nov 14 6:47 PM
Melissa,
I think COLLECT Stmt would do the thing.
See the follwoing link:
http://help.sap.com/saphelp_47x200/helpdata/en/fc/eb36d5358411d1829f0000e829fbfe/frameset.htm
<b> Instead of APPEND stmt, Use COLLECT.
COLLECT waIT_MATNR into IT_MATNR. </b>
Thanks
Kam
Note: Allot points for all worthful postings
Message was edited by: Kam
‎2005 Nov 14 6:42 PM
What is the structure of your internal table IT_MATNR? See if you can use COLLECT statement.
‎2005 Nov 14 6:43 PM
Is this whole code in the loop of IT_MATNR_TEMP?
‎2005 Nov 14 6:44 PM
i tried it, it doesnt work...
‎2005 Nov 14 6:45 PM
Can you give us the whole code starting with the loop of IT_MATNR_TEMP and also the structure of these tables?
Srinivas
‎2005 Nov 14 6:44 PM
Hi,
Instead of APPEND use COLLECT to summarize the quantity based on Material and Inventory type.
Thanks
Giridhar
‎2005 Nov 14 6:45 PM
where would i put COLLECT?
‎2005 Nov 14 6:47 PM
Melissa,
I think COLLECT Stmt would do the thing.
See the follwoing link:
http://help.sap.com/saphelp_47x200/helpdata/en/fc/eb36d5358411d1829f0000e829fbfe/frameset.htm
<b> Instead of APPEND stmt, Use COLLECT.
COLLECT waIT_MATNR into IT_MATNR. </b>
Thanks
Kam
Note: Allot points for all worthful postings
Message was edited by: Kam
‎2005 Nov 14 6:47 PM
I think you want to add quantities for every matnr and lgort, if so then use COLLECT instead of APPEND. Collect will sum up all the quantities fields so that it will get what you want.
‎2005 Nov 14 6:50 PM
I see that you are adding all the different inventories only if the storage location is 0345 or 0340 and type 02 or 04. What happens for all other cases?
Srinivas
‎2005 Nov 14 6:53 PM
Here is the modified code.
SELECT matnr labst umlme insme
einme speme retme lgort INTO TABLE t_mard
FROM mard
FOR ALL ENTRIES IN it_matnr_temp
WHERE matnr = it_matnr_temp-matnr
AND werks = '0111'
AND lgort IN ls_lgort.
LOOP AT it_matnr_temp.
LOOP AT t_mard WHERE matnr = it_matnr_temp-matnr.
IF t_mard-lgort = '0345' AND
it_matnr_temp-invty = '02'.
CLEAR l_matnr_quant_02.
l_matnr_quant_02 = t_mard-labst + t_mard-umlme + t_mard-insme +
t_mard-einme + t_mard-speme + t_mard-retme.
MOVE-CORRESPONDING it_matnr_temp TO it_matnr.
MOVE l_matnr_quant_02 TO it_matnr_temp-quant.
colelct it_matnr.
CLEAR it_matnr.
ELSEIF t_mard-lgort = '0340' AND
it_matnr_temp-invty = '04'.
CLEAR l_matnr_quant_04.
l_matnr_quant_04 = t_mard-labst + t_mard-umlme + t_mard-insme +
t_mard-einme + t_mard-speme + t_mard-retme.
MOVE-CORRESPONDING it_matnr_temp TO it_matnr.
MOVE l_matnr_quant_04 TO it_matnr_temp-quant.
COLLECT it_matnr.
CLEAR it_matnr.
ENDIF.
ENDLOOP.
ENDLOOP.
‎2005 Nov 14 6:50 PM
Melissa,
If you say the collect is not working, then check how you defined the quantity field in IT_MATNR table. For the collect statement to work the quantity field needs to a numeric data type field not a character data type field. Also make sure that you didn't have any other numeric fields in your internal table IT_MATNR, otherwise they will also get summed up.
Thanks
Giridhar
Message was edited by: Giridhar Nayudu