Unit conversions made easy
Sometimes there comes a situation where the conversion from one unit to another may become necessary.
Continue Reading This Article
Enjoy this article as well as all of our content, including E-Guides, news, tips and more.
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.