Our customer wants to force the UOM in return sales orders based on invoice, for some materials.
For example if an invoice, has UOM box and he makes a return sales order, the UOM in the return sales order is changed to Units.
For this we used user exit USEREXIT_MOVE_FIELD_TO_VBAP in MV45AFZZ, with function MD_CONVERT_MATERIAL_UNIT and it works.
Every field in the sales order is changed but in Condition detail in item Conditions the quantity is changed but not the UOM in fields Qty conversion RV61A-KMEI1 and Cond.base value RV61A-AWEIN.
Does anyone know how can I find out why SAP is not updating those values? I suspect there are some code that is copying those values.
Althought I do not think the problem is in the new code, here it is:
FORM userexit_move_field_to_vbap.
* VBAP-zzfield = xxxx-zzfield2.
IF sy-tcode EQ 'VA01'.
IF CVBRP-VBELN IS NOT INITIAL.
IF VBAK-VBTYP = 'H'.
DATA: lv_material type MARA-MATNR,
lv_um_in type MARA-MEINS,
lv_quantity type EKPO-MENGE,
lv_quantity_out type EKPO-MENGE,
lv_schme type MVKE-SCHME.
* LOOP AT CVBRP.
clear : lv_material,
lv_um_in,
lv_quantity,
lv_schme.
lv_material = cvbrp-matnr.
lv_um_in = cvbrp-vrkme.
lv_quantity = cvbrp-fkimg.
SELECT SINGLE SCHME
FROM MVKE
INTO lv_schme
WHERE MATNR = lv_material
AND VKORG = VVBRK-VKORG
AND VTWEG = VVBRK-VTWEG.
IF SY-SUBRC EQ 0.
CALL FUNCTION 'MD_CONVERT_MATERIAL_UNIT'
EXPORTING
i_matnr = lv_material
i_in_me = lv_um_in
i_out_me = lv_schme
i_menge = lv_quantity
IMPORTING
E_MENGE = lv_quantity_out
EXCEPTIONS
ERROR_IN_APPLICATION = 1
ERROR = 2
OTHERS = 3
.
IF sy-subrc EQ 0.
MOVE lv_quantity_out to cvbrp-fkimg.
MOVE lv_schme to cvbrp-vrkme.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDFORM. "USEREXIT_MOVE_FIELD_TO_VBAP