- SAP Community
- Groups
- Interest Groups
- Application Development
- Discussions
- Changing number of decimal places for Unit of Meas...

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.

Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Changing number of decimal places for Unit of Measure

Former Member

Options

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

2006 Mar 08 2:39 PM

2,239

- SAP Managed Tags:
- ABAP Development

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

2006 Mar 08 2:59 PM

402

- SAP Managed Tags:
- ABAP Development

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

2006 Mar 08 2:46 PM

402

- SAP Managed Tags:
- ABAP Development

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

2006 Mar 08 2:47 PM

402

- SAP Managed Tags:
- ABAP Development

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

2006 Mar 08 2:48 PM

402

- SAP Managed Tags:
- ABAP Development

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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

2006 Mar 08 2:54 PM

402

- SAP Managed Tags:
- ABAP Development

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

2006 Mar 08 2:57 PM

402

- SAP Managed Tags:
- ABAP Development

<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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

2006 Mar 08 2:59 PM

403

- SAP Managed Tags:
- ABAP Development

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

2006 Mar 08 3:04 PM

402

- SAP Managed Tags:
- ABAP Development

Hi All,

Thanks for the quick and helpful responces!!

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

Roman