07-31-2007 6:53 AM
Hi ,
can any one tell wat is the significance of input and kzmeinh in the FM material_unit_conversiom.
i have to convert the KG into CSE ...wat are the parameters to be passed .
thanks
kiran
07-31-2007 6:57 AM
Hi Kiran,
See the Function Module Documentation,
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.
Thanks,
Reward If Helpful.
07-31-2007 6:57 AM
Hi
It is just an indicator whose: INPUT refers to MEINH, just leave it as space
pass the MATNR and MEINS fields compulsory and execute
<b>Reward points for useful Answers</b>
Regards
Anji
07-31-2007 6:58 AM
HI,,
Please try this FM.
MD_CONVERT_MATERIAL_UNIT
MATERIAL_UNIT_CONVERSION
MC_UNIT_CONVERSION
UNIT_CONVERSION_SIMPLE
using MATERIAL_UNIT_CONVERSION is as shown
report zrich_0002.
data: input type p decimals 3 value '10.000'.
data: begin of xtmp,
menge type mseg-menge,
meins type mseg-meins,
end of xtmp.
data: imara like mara.
Get base UOM
select single * from mara into imara
where matnr = '000000000040006541'.
The uoms must be of the internal format, check against T006a
do conversion
call function 'MATERIAL_UNIT_CONVERSION'
exporting
input = input
matnr = imara-matnr
meins = 'GLL' " Must be internal
meinh = 'OZA' " Must be internal
importing
meins = xtmp-meins
output = xtmp-menge
exceptions
conversion_not_found = 01
input_invalid = 02
material_not_found = 03
meinh_not_found = 04
meins_missing = 05
no_meinh = 06
output_invalid = 07
overflow = 08.
check sy-subrc = 0.
<b>regards</b>
07-31-2007 6:58 AM
Hi,
Check SAP's example
data: DATA: umrez TYPE f, umren TYPE f.
CALL FUNCTION 'MATERIAL_UNIT_CONVERSION'
EXPORTING
matnr = matnr
meinh = display_unit
meins = base_unit
no_output = 'X'
IMPORTING
umrez = umrez
umren = umren
EXCEPTIONS
conversion_not_found = 1
input_invalid = 2
material_not_found = 3
meinh_not_found = 4
meins_missing = 5
no_meinh = 6
output_invalid = 7
overflow = 8
OTHERS = 9.
IF sy-subrc <> 0.
umrez = umren = '1'.
ENDIF.
Reward if useful!
07-31-2007 7:02 AM
" Converting material quantities to different unit of measure in ABAP.
Each material in SAP has its standard, base unit of measure (stored in MARA-MEINS). To allow using alternative units, those can be maintained per material in table MARM. A common requirement for ABAPer is to convert material quantity from one unit to another, most likely from an alternative unit to the base one, to be able to summarize the report results.
To do the conversion, SAP provides the function module MATERIAL_UNIT_CONVERSION. Its parameter names are not self-explaining, and for my own purposes I have a simple wrapper form that I use to convert quantities from alternative to base UoM. The form is using data caching technique that I described in one of my earlier posts.
form convert_to_base_uom
using pf_matnr type matnr
pf_menge_in type gsmng
pf_meins_in type meins
changing pf_menge_out type gsmng
pf_meins_out type meins.
* define internal table to cache the base UOM
types: begin of lty_meins_rec,
matnr type matnr,
meins type meins,
end of lty_meins_rec.
types:
lty_meins_tab type hashed table of lty_meins_rec
with unique key matnr.
data:
ls_wa type lty_meins_rec.
statics:
lt_meins type lty_meins_tab.
* first, find the base UOM
clear pf_meins_out.
read table lt_meins into ls_wa
with table key matnr = pf_matnr.
if sy-subrc = 0.
pf_meins_out = ls_wa-meins.
else.
select single meins
from mara
into ls_wa-meins
where matnr = pf_matnr.
if sy-subrc 0. "doesn't exist. try PC
ls_wa-meins = 'ST'.
endif.
ls_wa-matnr = pf_matnr.
pf_meins_out = ls_wa-meins.
insert ls_wa into table lt_meins.
endif.
* now convert the qty
if pf_meins_in = pf_meins_out.
pf_menge_out = pf_menge_in.
else.
call function 'MATERIAL_UNIT_CONVERSION'
exporting
input = pf_menge_in
kzmeinh = 'X'
matnr = pf_matnr
meinh = pf_meins_in
meins = pf_meins_out
type_umr = '3'
importing
output = pf_menge_out
exceptions
conversion_not_found = 1
input_invalid = 2
material_not_found = 3
meinh_not_found = 4
meins_missing = 5
no_meinh = 6
output_invalid = 7
overflow = 8
others = 9.
endif.
endform.
reward points if it is usefull...
Girish