Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

puprose of this FM MC_UNIT_CONVERSION?

subbarao_ilam
Explorer
0 Kudos

Hi All,

What is the purpose of the below FM.

MC_UNIT_CONVERSION

what are all the inputs this will take and what could be output,

pls let me know.

Subu

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Subbu,

Sometimes there comes a situation where the conversion from one unit to another may become necessary. One such situation could be to convert the order unit in the purchase order to the base unit measure of the material. The usage of the function module 'MC_UNIT_CONVERSION' could ease the job. The user must supply the source unit of meausre and the target unit of measure. The function module in turn returns a conversion factor. This conversion factor needs to be multiplied with the value in source units in order to get the value in target units. The various units of measure along with the conversion ratios between them are maintained in the table T006.

sample code for your referance.

REPORT Unit_Conversion .

PARAMETERS :
p_svalue TYPE p DECIMALS 2,
p_sunit  TYPE mara-meins,
p_tunit  TYPE mara-meins.

DATA:
w_target_value TYPE f,
l_factor TYPE f.

CALL FUNCTION 'MC_UNIT_CONVERSION'
     EXPORTING
          nach_meins           = p_tunit                       " Target unit
          von_meins            = p_sunit                       " Source unit
    IMPORTING
         umref                = l_factor
    EXCEPTIONS
         conversion_not_found = 1
         material_not_found   = 2
         nach_meins_missing   = 3
         overflow             = 4
         von_meins_missing    = 5
         OTHERS               = 6
          .
IF sy-subrc <> 0.
  MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
          WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
  w_target_value = p_svalue * l_factor.
  WRITE :
    'The value after conversion to the target unit of measure is',
     w_target_value.
ENDIF.

1 REPLY 1

Former Member
0 Kudos

Hi Subbu,

Sometimes there comes a situation where the conversion from one unit to another may become necessary. One such situation could be to convert the order unit in the purchase order to the base unit measure of the material. The usage of the function module 'MC_UNIT_CONVERSION' could ease the job. The user must supply the source unit of meausre and the target unit of measure. The function module in turn returns a conversion factor. This conversion factor needs to be multiplied with the value in source units in order to get the value in target units. The various units of measure along with the conversion ratios between them are maintained in the table T006.

sample code for your referance.

REPORT Unit_Conversion .

PARAMETERS :
p_svalue TYPE p DECIMALS 2,
p_sunit  TYPE mara-meins,
p_tunit  TYPE mara-meins.

DATA:
w_target_value TYPE f,
l_factor TYPE f.

CALL FUNCTION 'MC_UNIT_CONVERSION'
     EXPORTING
          nach_meins           = p_tunit                       " Target unit
          von_meins            = p_sunit                       " Source unit
    IMPORTING
         umref                = l_factor
    EXCEPTIONS
         conversion_not_found = 1
         material_not_found   = 2
         nach_meins_missing   = 3
         overflow             = 4
         von_meins_missing    = 5
         OTHERS               = 6
          .
IF sy-subrc <> 0.
  MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
          WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
  w_target_value = p_svalue * l_factor.
  WRITE :
    'The value after conversion to the target unit of measure is',
     w_target_value.
ENDIF.