Birim Çevirme
MD_CONVERT_MATERIAL_UNIT kullanarak birim çevirme örneği.
IF ls_resb-meins NE lv_meins.
PERFORM f_convert_meins USING ls_resb-matnr
ls_resb-bdmng
ls_resb-meins
lv_meins
CHANGING ls_resb-bdmng.
ENDIF.
*&---------------------------------------------------------------------*
*& Form F_CONVERT_MEINS
*&---------------------------------------------------------------------*
FORM f_convert_meins USING p_matnr
p_fr_miktar
p_fr_meins
p_to_meins
CHANGING p_to_miktar.
DATA: lv_fr_menge LIKE ekpo-menge,
lv_to_menge LIKE ekpo-menge.
lv_fr_menge = p_fr_miktar.
CALL FUNCTION `MD_CONVERT_MATERIAL_UNIT`
EXPORTING
i_matnr = p_matnr
i_in_me = p_fr_meins
i_out_me = p_to_meins
i_menge = lv_fr_menge
IMPORTING
e_menge = lv_to_menge
EXCEPTIONS
ERROR_IN_APPLICATION = 1
ERROR = 2
OTHERS = 3.
IF sy-subrc = 0.
p_to_miktar = lv_to_menge.
ENDIF.
ENDFORM.
***********************************************
LOOP AT lt_mchb ASSIGNING FIELD-SYMBOL().
lv_ton = -clabs.
IF NE gc_ton.
me->convert_meins( EXPORTING iv_matnr = -matnr
iv_fr_miktar = lv_ton
iv_fr_meins = -meins
iv_to_meins = gc_ton
IMPORTING ev_to_miktar = lv_ton ).
ENDIF.
ev_mevton = ev_mevton + lv_ton.
ENDLOOP.
UNASSIGN .
CLASS lcl_main DEFINITION CREATE PRIVATE FINAL.
PRIVATE SECTION.
METHODS:
convert_meins IMPORTING iv_matnr TYPE matnr
iv_fr_miktar TYPE bstmg
iv_fr_meins TYPE meins
iv_to_meins TYPE meins
EXPORTING ev_to_miktar TYPE bstmg.
ENDCLASS.
METHOD convert_meins.
DATA: lv_fr_menge TYPE bstmg,
lv_to_menge TYPE bstmg.
lv_fr_menge = iv_fr_miktar.
CALL FUNCTION `MD_CONVERT_MATERIAL_UNIT`
EXPORTING
i_matnr = iv_matnr
i_in_me = iv_fr_meins
i_out_me = iv_to_meins
i_menge = lv_fr_menge
IMPORTING
e_menge = lv_to_menge
EXCEPTIONS
error_in_application = 1
error = 2
others = 3.
IF sy-subrc = 0.
ev_to_miktar = lv_to_menge.
ELSE.
CLEAR ev_to_miktar.
ENDIF.
ENDMETHOD.