2006 Mar 08 2:39 PM
Hi All,
I have a requirement to convert a quantity in one unit of measure to another (custom) unit of measure.
The issue is that the custom unit of measure has 4 decimal places (customer requirement). I found function module MD_CONVERT_MATERIAL_UNIT which does the trick for regular, 3 decimal places, UoM's. It won't output 4 decimal places since the output data type is EKPO-MENGE, which has 3 decimal places.
Does anyone have experience with trying to convert material's UoMs into 4 or more decimal places?
Thanks!
2006 Mar 08 2:59 PM
hI Roman,
Declear the variable with decimal 4.
data : v_menge(10) type p decimals 4.
pass that ekpo-menge to that variable. i think this will solve ur problem.
Thanks
Vikranth
2006 Mar 08 2:46 PM
Hi Roman,
If that is a Custom Unit Of measure, then you must be knowing the Conversion rules.
I.e. x KGS = y NUs..where NU is a new unit.
Based on the conversion formula, you should calculate the amount..i.e 1 KG = y / x Nus..
similarly, for Z Kgs, v_result = z * y / x NUs..
The result of this calculation should be held in a variable declared as
Data : v_result(20) type p decimals 4.
REgards,
Ravi
2006 Mar 08 2:47 PM
Hi,
You can copy the FM into a Z object, and have a variable of type <b>FRMLD_QUAN9_4 (QUAN Field with 9 Predecimal and 4 Decimal Places)</b> for output with 4 decimal places.
Regards,
Raj
2006 Mar 08 2:48 PM
data: custom_var type p decimals 4
write var to custom_var (type p decimals 4)
u can directly write the variable to custom variable of desired decimals.
2006 Mar 08 2:54 PM
Hi,
Please the following OSS notes.
311301 : Rounding: Incorrect conversion to a SU w. dimension
873626 : AM: Conversion factors for unit of measure
202751 : CO: incorrect quantity conversion w/ material ref
195838: Load build:Rounding difference of purch.ord.quantity
Thanks,
Ramakrishna
2006 Mar 08 2:57 PM
<b>round_f_to_15_decs</b> round variable of type f to 15 decimals
Sometimes type F (float) is used to represent exact data (Amounts, Quantities):
if values are to big to be represented as Packed (> 31 decimals)
to significally improve performance of calculations, e.g. in statistical reports
G_DECIMAL_PLACES_GET
REPORT Z_ROUNDING .
DATA: float TYPE f,
amount TYPE p DECIMALS 2,
correctamount TYPE p DECIMALS 2,
chars(5) TYPE c value '1.005'.
CLASS cl_abap_math DEFINITION LOAD.
correctamount = chars.
WRITE: / 'Exactly:', chars,
/ 'Correct Amount:', correctamount.
float = chars.
amount = float.
skip 2.
WRITE: / '==== Usual Processing:',
/ 'Float:', float,
/ 'Decimals 3:', float DECIMALS 3,
/ 'Decimals 2:', float DECIMALS 2,
/ 'Amount:', amount.
float = cl_abap_math=>round_f_to_15_decs( float ).
amount = float.
skip 2.
WRITE: / '==== Correct Processing:',
/ 'Float:', float,
/ 'Decimals 3:', float DECIMALS 3,
/ 'Decimals 2:', float DECIMALS 2,
/ 'Amount:', amount.
2006 Mar 08 2:59 PM
hI Roman,
Declear the variable with decimal 4.
data : v_menge(10) type p decimals 4.
pass that ekpo-menge to that variable. i think this will solve ur problem.
Thanks
Vikranth
2006 Mar 08 3:04 PM
Hi All,
Thanks for the quick and helpful responces!!
Khimavath had the simple idea of changing v_menge(10), thanks!!! it worked!
Roman