03-31-2008 3:07 PM
Hi experts,
Is there anyone share me how to use FM MATERIAL_UNIT_CONVERSION?
Can I use this to convert Volume to KG and vise versa?
eg. 20M3 to 20000KG; 10L to 12000KG
Thanks
03-31-2008 3:11 PM
This function module converts a quantity from one unit of measurement to another. A requirement for this is that the units of measurement relate to a material. One of them must be the base unit of measure of the material, while the other must be defined as an alternative unit of measure for the material or be capable of being converted to an
alternative unit of measure as per table T006.
You are recommended declaring the transfer parameters for the quantities and the conversion factors as type F fields since the runtime required for conversion is substantially less than with type P or type I fields and also because the exception OVERFLOW cannot then occur.
If the transfer parameters for the conversion factors are of type P (packed number), the system assumes that you require conversion with 5-digit accuracy. If they are of type I (integer), the system assumes that you require conversion with 10-digit accuracy. (See also the documentation on transfer parameter TYPE_UMR.)
Example
DATA: MATNR LIKE MARA-MATNR,
MEINS LIKE MARA-MEINS,
MEINH LIKE MARM-MEINH,
INPUT TYPE F,
OUTPUT TYPE F,
UMREN TYPE F,
UMREZ TYPE F,
KZMEINH TYPE C.
. . .
CALL FUNCTION 'MATERIAL_UNIT_CONVERSION'
EXPORTING
INPUT = INPUT
KZMEINH = KZMEINH
MATNR = MATNR
MEINH = MEINH
MEINS = MEINS
IMPORTING
OUTPUT = OUTPUT
UMREN = UMREN
UMREZ = UMREZ
EXCEPTIONS
CONVERSION_NOT_FOUND = 01
INPUT_INVALID = 02
MATERIAL_NOT_FOUND = 03
MEINH_NOT_FOUND = 04
MEINS_MISSING = 05
OUTPUT_INVALID = 06
OVERFLOW = 07.
Hope this Helps.
Regards
Vinayak
03-31-2008 3:11 PM
This function module converts a quantity from one unit of measurement to another. A requirement for this is that the units of measurement relate to a material. One of them must be the base unit of measure of the material, while the other must be defined as an alternative unit of measure for the material or be capable of being converted to an
alternative unit of measure as per table T006.
You are recommended declaring the transfer parameters for the quantities and the conversion factors as type F fields since the runtime required for conversion is substantially less than with type P or type I fields and also because the exception OVERFLOW cannot then occur.
If the transfer parameters for the conversion factors are of type P (packed number), the system assumes that you require conversion with 5-digit accuracy. If they are of type I (integer), the system assumes that you require conversion with 10-digit accuracy. (See also the documentation on transfer parameter TYPE_UMR.)
Example
DATA: MATNR LIKE MARA-MATNR,
MEINS LIKE MARA-MEINS,
MEINH LIKE MARM-MEINH,
INPUT TYPE F,
OUTPUT TYPE F,
UMREN TYPE F,
UMREZ TYPE F,
KZMEINH TYPE C.
. . .
CALL FUNCTION 'MATERIAL_UNIT_CONVERSION'
EXPORTING
INPUT = INPUT
KZMEINH = KZMEINH
MATNR = MATNR
MEINH = MEINH
MEINS = MEINS
IMPORTING
OUTPUT = OUTPUT
UMREN = UMREN
UMREZ = UMREZ
EXCEPTIONS
CONVERSION_NOT_FOUND = 01
INPUT_INVALID = 02
MATERIAL_NOT_FOUND = 03
MEINH_NOT_FOUND = 04
MEINS_MISSING = 05
OUTPUT_INVALID = 06
OVERFLOW = 07.
Hope this Helps.
Regards
Vinayak
03-31-2008 3:29 PM
Hi,
data : erfmg like affw_tab-erfm,
matnr like affw_tab-matnr,
yx TYPE xfeld VALUE 'X',
erfme like affw_tab-erfme,
meins like resb-meins,
bdmng like tmp_lresb-bdmng.
CALL FUNCTION 'MATERIAL_UNIT_CONVERSION'
EXPORTING
input = affw_tab-erfmg
kzmeinh = yx
matnr = affw_tab-matnr
meinh = affw_tab-erfme
meins = resb-meins
IMPORTING
output = tmp_lresb-bdmng
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0.
tmp_lresb-bdmng = 0.
ENDIF.
Regards,
Morris Bond.
Reward Points if Helpful.