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: 

Changing number of decimal places for Unit of Measure

Former Member
0 Kudos
2,284

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!

1 ACCEPTED SOLUTION

Former Member
0 Kudos
447

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

7 REPLIES 7

former_member181962
Active Contributor
0 Kudos
447

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

Former Member
0 Kudos
447

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

Former Member
0 Kudos
447

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.

venkata_ramisetti
Active Contributor
0 Kudos
447

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

vinod_gunaware2
Active Contributor
0 Kudos
447

<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.

Former Member
0 Kudos
448

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

0 Kudos
447

Hi All,

Thanks for the quick and helpful responces!!

Khimavath had the simple idea of changing v_menge(10), thanks!!! it worked!

Roman