cancel
Showing results for 
Search instead for 
Did you mean: 

Kg to mg conversion!!!!

Former Member
0 Kudos

HI, QM experts,

I am facing a problem here;

The stock for a material is maintained in Kg (The Base UOM of material is Kg) now I want to issue the material in Mg (miligram) but it is not allowing me and throing an error hence it's not able to calculate the stock from Kg to Mg because there is only 5 digits allowed in the conversion factor..

Pls provide some inputs over this.

With Best Regards,

Shyamal H. Joshi

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hello,

I think you have to maintain Kg to Gm and then Gm to Mg conversions in Material Master to overcome 5 digit restriction.

Thanks,

Venu

Former Member
0 Kudos

Dear Veenu,

For a material you can maintain the conversion factor against the Basu UOM only.

Here the Base UOM for my material is Kg so can only maintain it form Kg to Gm and Kg to Mg.

Dear friends pls correct me if i m wrong!!

Reqards,

Shyamal

JL23
Active Contributor
0 Kudos

hi Venu, all alternative unit can only be related to the base unit.

check the alternative data view. The base unit is defaulted to the entire column and cannot be changed.

JL23
Active Contributor
0 Kudos

Generally, the alternative units of measure and the base unit of measure should result in quantities that are in the same dimension since the conversion factors may not be larger than 99999/1 and not smaller than 1/99999.

See OSS note 362932. It has all kind of information about conversion, rounding errors, recommendation on how to choose the correct base unit of measure.....

I recommend to create an extra material master.

Former Member
0 Kudos

Hi, Jourgen,

I am sorry but, Pls guide me from where can I find this note.

Once I have clicked on a link for a number that was very similar to you have given and suddenly I was asked for my ID and Password.

Was it asking my PCs?

Pls giude hence I am a fresher.

Regards,

Shyamal

JL23
Active Contributor
0 Kudos

http://service.sap.com/notes

you need an ID to logon, Ask your basis team, they usually maintain users and request access keys.

Edited by: Jürgen L. on Feb 22, 2008 4:25 PM

Former Member
0 Kudos

Sirji,

It's displaying me following error,

What I need to do to access it,

Error Message - Authorization Error

An authorization error occured when you tried to access the requested document.

This may be because you are not authorized to access this document.

regards,

Shyamal

Former Member
0 Kudos

Thanks for your really valuable inputs

Former Member
0 Kudos

Here i have pasted the OSS note 362932

Summary

Symptom

There are rounding problems when using product units of measure.

Other terms

KZWSO, KZWSM, XU033, XU056, XU040, MURC, T006

Reason and Prerequisites

This note describes the conversion with product units of measure and gives recommendations on how you can avoid rounding problems.

Solution

1. General information on the quantity conversion in the SAP System

a) Base unit of measure and alternative units of measure

The base unit of measure is the unit of measure which is used to manage the stocks of the material.The system converts all quantities which you enter in other units of measure (alternative units of measure) into the base unit of measure.

To be able to convert a quantity whose unit of measure is not the same as the base unit of measure into the base unit of measure, the system requires a conversion factor.

Quantity in base unit of measure = Quantity in alternative unit of measure * conversion factor

b) Numerator and denominator

The values of the conversion factors are saved as the quotient. The numerator and denominator of the quotient are whole numbers with a maximum of 5 places.

Example 1: Numerator and denominator

The alternative unit of measure is piece (PCS). The base unit of measure is kilo (KG). 3 pcs weigh 5 KG, that is, the conversion ratio is 3 pcs = 5 KG.

The resulting conversion factor is: 5/3 KG/PCS

The quotient of the conversion factor is defined such that the numerator of the quantity in the base unit of measure corresponds to the denominator of the quantity in the alternative unit of measure.

Therefore, the quotient here is also 5/3: the numerator is 5 and the denominator is 3.

Example 2: Whole number numerators and denominators

The numerator and denominator are in integer form, that is, if 3.14 M2 corresponds to one piece, this must be represented as 314 M2 = 100 PCS or reduced, 157 M2 = 50 PCS.

In general, decimal conversion factors can be transferred exactly to quotients by means of a continued fraction development (this applies to finite and periodic decimal fractions only, while as a rule conversion factors do meet this requirement).

Approximations for a decimal fractions can be obtained by a premature termination of the continued fraction development. In the quantity conversion environment, the criterion for a termination is the maximum number of places for numerator and denominator.

Using ABAP function CONVERT_TO_FRACT5, you can obtain the best approximation for a given decimal fraction as a quotient with maximally 5-digit numerator and denominator.

If the continued fraction development results in an approached decimal fraction, this decimal fraction is generally cyclic and can therefore not be represented with finite number of places.

In any case, the numerator and denominator as a result of a continued fraction development do not have the same factors.

Literature:

Knuth, D.E.: The Art of Computer Programming, Volume 2, Seminumerical Algorithms, Second Edition. Reading: Addison-Wesley 1981. S. 313-315, 339-341, 363 (40. and 43.).

Example 3: Too large numerators and denominators

When 120000 CM3 = 0,2 tons (TO), you can no longer save numerator and denominator of conversion ratio 600000 CM3 = 1 TO as numerator and denominator may have maximally five digits.

Here, you must either select a larger volume unit or a smaller unit of weight: With DM3 the conversion ratio would be 600 DM3 = 1 TO, with KG the conversion ratio would be 600 CM3 = 1 KG.

Generally, the alternative units of measure and the base unit of measure should result in quantities that are in the same dimension since the conversion factors may not be larger than 99999/1 and not smaller than 1/99999.

c) Choosing the base unit of measure

When choosing the base unit of measure, you should take the following into account:

If the base unit of measure is selected too small, quantities or values might become too large (see Example 4a).

The larger you select the base unit of measure to be, the more "inaccurately" the system can manage the stocks (see Example 4b).

If the base unit of measure shall be a dimensionless unit (a packing unit such as piece, box, and so on), you must select the smallest of the dimensionless units of measure as a base unit of measure (see Example 5).

Basically, the same applies for dimension afflicted (physical) units of measure: The base unit of measure is supposed to be a unit of a certain dimension (for example a length), and both metric and non-metric units are used (for example meter and foot), then you should select the smallest of the used dimension afflicted units as a base unit of measure. This is not obligatory, because quantities in physical units of measure generally are - and also should be - granted to decimal places; however, you should note in any case that the same effects occur as described in example 5.

When you use of metric and non-metric units of measure, it is recommended to set the number of the rounding decimal places for these dimension afflicted units of measure to 3 (as the number of the decimal places of the quantity fields) in order to avoid different side effects as the system does not round in the same way in all transactions (see also section 1.d).

The base unit of measure can no longer be changed (see Note 138767).

Example 4a: Stock quantities are too high because the base unit of measure is too small

If you select the base unit of measure too small, the system might no longer be able to represent stock quantities with the available places. As quantities are generally also linked to values, the number of places for the value items should also be taken into account.

A paper material is lead up to now in PCS (= individual sheets of paper).Since no individual PCSs are generally sold, the new unit of measure TPC (= a thousand pieces) has instead been defined.

Example 4b: Accuracy limit of the base unit of measure

For example, if a material is managed in TO, the accuracy with which stocks can be managed is 1 KG (with 3 decimal places for quantity fields).

Example 5: Dimensionless base unit of measure (Packing unit)

The example from Note 122471 is used as a basis and placed in this context set: A material is managed in boxes (BOX). There is an alternative unit of measure PCS. The conversion ratio is 24 PCS = 1 BOX.

It does not result in any rounding problems when you post multiples of 3 PCS = 0.125 BOX (with 3 decimal places for quantity fields). In the following, this conversion ratio will be specified as "Increment".

If you want to post per piece, you must consider the following:

Goods movements should not be posted in units of measure that are smaller than the base unit of measure if they are not multiples of the increment.

For example, you enter a goods receipt of 13 PCS, the system stores 0.542 BOX in the stock (13 / 24 = 0.54166666...).

If you then want to display the stock in PCS, 13.008 PCS are displayed (0.542 * 24 = 13.008).

This effect is caused because the stock is exclusively managed in base units of measure, quantity fields with finite decimal places are saved and if the alternative unit of measure is smaller than the base unit of measure. In other words: The representation of quantities from PCS to BOX and back to PCS is not unique for quantities that are not multiples of the increment.

If you enter a goods receipt in base unit of measure - or an alternative unit of measure that is larger than the base unit of measure (e.g. pallets) - , the system does no longer generate rounding errors (however, it may nevertheless come to quantities in PCS with decimal places, if not multiples of the increment are posted).

In order to avoid the above described situation, if possible, you should select the smallest unit of measure as a dimensionless base unit of measure so that the alternative units of measure are a multiple of the base unit of measure.

If you now select the smallest unit of measure as a base unit of measure, the system does no longer generate rounding errors with goods movements in PCS (Base unit of measure) or in BOX (Alternative unit of measure). However, quantities in BOXes which are not multiples of the increment will still result in quantities in PCS with decimal places (instead of 0.333 BOX = 7.992 PCS you need to post 8.000 PCS -> 0.333 BOX).

In addition, you must now take the following into account: You can at least only post the quantities in alternative unit of measure as a complete stock removal which are multiples of the increment. In other words: Postings of complete stock removals of quantities in alternative units of measure which are larger than the base unit of measure generally result in positive or negative remaining quantities.

For example, if 13 PCS are contained in the stock, this can be displayed in the stock overview as 0.542 BOX. If you now want to post 0.542 CR as goods issue, this will result in an error as a negative remaining quantity of 0.008 PCS would be created.

Remark:

This example applies in the same way to metric and non-metric units of measure of the same dimension, as well as for units of measure of different dimensions. In these cases, the quantities in alternative unit of measure are mostly not multiples of the quantity in base unit of measure.

Conclusion:

Mostly, all quantities that are not multiples of the increment cannot be converted uniquely into each other. Among other things, the effects described in example 5 and example 8.2 will occur. Regarding "one-to-one" and on the general calculation of the increment also refer to section 2.e.

d) Maintaining the units of measurement

During the maintenance of the units of measure (Transaction CUNI) for avoiding or minimizing conversion errors you must consider the following:

The conversion factor, consisting of numerator, denominator, and exponent, should be maintained in such a way that the exponent is Zero, and numerator and denominator have maximally five digits, as in most transactions there is a restriction to this number of places.

The entered numerator and the denominator are not reduced, that is, they are not automatically divisor-external. SAP recommends to maintain numerator and denominator divisor-externally as the quotient is not always reduced within the system before it is converted. In case of large quantities and long numerators or denominators the system might generate conversion errors due to the limited number of places of data types (with floating point numbers in SAP Systems with double accuracy according to the IEEE 754 standard, for example, only the first 15 decimal places can be displayed reliably). The smaller numerator and denominators are, the larger the quantities that can be converted without rounding errors.

No cross-dimension check of the conversion factors occurs. For example are 381 M = 1250 FT. From this follows 145161 M2 = 1562500 FT2. Mostly, however, certain approximate values that are not consistent for the respective units of length are maintained for the non-metric surface units of measure. For the conversion with non-metric units refer to Note 23771.

Please consider the two fields for the decimal places: For example the display decimal place is taken into account in the list output; onto the rounding decimal place, for example, it is rounded during the creation of a production order. The rounding decimal place is not, however, considered by every transaction so that particularly in the case of a simultaneous use of metric and non-metric units it is recommended to set the rounding decimal places of these units of measurement to 3 (like the number of the decimal places of the quantity fields). Additional information is available in Note 77525.

A unit of measurement family can be used unrestrictedly, for example to limit the selectable physical alternative units of measure during the use of the variant configuration.

In a SAP system group of several SAP Systems the settings must be equal for all used units of measurement. Please refer to Notes 492979 and 595742.

In case of connecting Non-SAP Systems, you must adjust the settings on each other.

2. Batch-specific units of measure - product units of measure

The batch-specific material unit of measure is an alternative unit of measure of a material for which the conversion ratio into the base unit of measure can be defined batch-specifically.

Whereas for the other alternative units of measure, the conversion ratio is predefined in the material, you define the planned (average) conversion factor for the batch-specific material units of measure in the material and the actual conversion factor into the base unit of measure on the batch.

You use batch-specific units of measure if the conversion ratio of the unit of measure into the base unit of measure can be different for different batches of a material.

Batch-specific material units of measure can be proportional or product units of measure.

a) Characteristic for saving the conversion factor

The conversion factor between a batch-specific material unit of measure and the base unit of measure is saved as a valuation of a characteristic in the batch classification. The conversion factor is saved as a finite decimal fraction with a maximum of 15 digits (places before and after the decimal point). The actual conversion factor is a quotient which is derived internally from the stored decimal fraction (see section "Displayability of the conversion factor as a five-digit fraction" further below).

Remark:

Numeric characteristic valuations are stored internally as floating point number. When storing characteristic valuations in numeric format in the database, the values are rounded to the format defined by the template. For this reason, when newly creating batch classifications, values may differ from the values stored in the database afterwards. Therefore, calculated numeric values which are used in the dependency for further calculations (e.g. for calculating a conversion factor) must be rounded explicitly to the format defined in the characteristic in the dependency!

In this connection, please also refer to Note 399308 which describes this subject for variant configurations: In particular, classification and configuration valuations differ from numeric characteristics in the database.

In addition, the following facts which have to be considered in borderline cases are to be noted:

When storing in and subsequently reading from the database, the original floating point number is not returned in all cases.

This behavior occurs for certain values, where those values differ (depending on the implementation) for the databases used. This behavior is not caused by a database error, however, but by a missing definition in the SQL standard.

The SQL standard determines that the accuracy of floating point numbers is to be guaranteed up to 15 places after the decimal point. It does not define that the floating point numbers returned by the database are to be rounded to the IEEE 754 standard with double accuracy. This is the reason why the unambiguity during storage in databases is presently not guaranteed for floating point numbers in the SAP environment.

The program coding in the correction from Note 680228 may serve as a template for a corresponding rounding logic in a variant function.

Example 6: Decimal fraction

The base unit of measure of a material is kilo and the product unit of measure is piece. 3 PCS of the batch have a weight of 10 KG. The conversion factor delivers the periodic decimal fraction 3.33333333 ... KG/PCS (if PCS is defined as the leading product unit of measure for goods receipt in the material master).

In this example, the format of the characteristic for the conversion factor is defined as numeric without exponential display with a total of 8 digits and 3 decimal places. This allows exact posting by pieces, and the resulting conversion factor is 3.333 KG/PCS (see also further below: case 1A with example 7).

b) What does the accuracy of the conversion depend on?

The accuracy of the conversion depends on several factors:

Number of rounding decimal places of the alternative unit of measure

Number of rounding decimal places of the base unit of measure

Value or number of places of the conversion factor (the rounding decimal places of the unit of measure [that is defined in the characteristic of the conversion factor] are not analyzed by the system; usage in the object dependencies of the classification is possible)

Case 1A: Product units of measure in whole numbers (0 rounding decimal places)

If you are using (countable) product units of measure in whole numbers as a piece, package or role and the base unit of measure is a unit of measure such as meters, kilogram, or square meters, then you use the same number of decimal places in the conversion characteristic as the number of rounding decimal places in the base unit of measure.

The conversion factor must not have more than this number of decimal places because otherwise, the one-to-one is no longer ensured during the conversion of PCS into the base unit of measure and back for all multiples of 1.

You define the conversion factor with "Calculation basis- from proportion/product unit of measure" as follows as a fraction:

Conversion factor = Base unit of measure / Product unit of measure

With that, the rounding differences described in example 8.2 do not occur in the SAP system. However, the quantity in base unit of measure can easily deviate from reality.

Example 7: Diverging quantity in base unit of measure

You enter a goods receipt of 3 piece. The total weight is 10 KG.In the SAP system, the conversion factor is stored with 3.333 KG/PCS, in the case that KG is defined with 3 rounding decimal places. Then the quantity in the base unit of measure in the system is 9.999 KG and not 10 KG.

Case 1B: Product units of measure with less than 3 rounding decimal places

Definition:

N = Rounding decimal places Base unit of measure

- Rounding decimal places Product unit of measure

The conversion factor should have, at the most, N decimal places to avoid rounding errors.

Remark:

This rule is only useful for product units of measure that have less than 3 rounding decimal places since the quantity in product unit of measure is rounded in case of 3 rounding decimal places during the one-to-one check of the application (see below).

Example 8: Determining the number of decimal places of the conversion factor between base unit of measure KG and the product unit of measure TPC (one thousand pieces)

N = rounding decimal places KG - rounding decimal places TPC

= 3 - 2 = 1

If you use a conversion factor with 1 decimal place, no rounding errors occur when multiples of 0.01 TPC = 10 PCS are posted.

Example 8.1:

The conversion factor is 3.3 KG/TPC.

0.01 TPC = 10 PCS weighs 0.033 KG. 0.03 TPC = 30 PCS weighs 0.099 KG.

Example 8.2:

If you use a conversion factor with 2 decimal places, rounding errors occur:

The conversion factor is 3.33 KG/TPC.

Goods receipt 0.03 TPC = 0.0999 KG (is rounded off to 0.100 KG)

Goods issue 0.01 TPC = 0.0333 KG (is rounded off to 0.033 KG)

0.01 TPC = 0.0333 KG (is rounded off to 0.033 KG)

0.01 TPC = 0.0333 KG (is rounded off to 0.033 KG)

As a result of the rounding error, a residual quantity of 0.001 KG remains in the stock.

Remark:

If multiples of 0.1 TPC = 100 PCS would be posted, then all entry quantities would be convertable one-to-one into the base unit of measure in this case, and no rounding differences would occur. This can be achieved if a product unit of measure TPC (one thousand pieces) is defined with 1 rounding decimal place.

Case 2: Product units of measure with 3 rounding decimal places

If you use product units of measure with 3 rounding decimal places such as kilograms, barrels, square meters, or meters, you should use a conversion characteristic with the highest degree of accuracy possible:

Select the standard exponential display: the numeric characteristic should then have a total of 15 places and have a maximum number of 14 decimal places.

Then, if the exponential display is too inconvenient for your end user, then you can also use a normal decimal format as a fixed point number with a total of 15 places depending on the value range of the conversion factor. Create the number of decimal places such that the number of predecimal places is defined so that the largest factor is just displayable (more than 5 predecimal places does not make sense because the conversion factor must never be larger than 99999/1).

Example 9: Square meter and kilo

You enter a goods receipt of 3 M2 with a total weight of 4 KG.

The conversion factor 1.33333 ... KG/M2 should be stored as exactly as possible.

A factor of 1.33333333333334E+00 KG/M2 results in the standard exponential display.

You can also define the conversion factor in normal decimal format. The maximum factor is less than 10 KG/M2. The conversion factor should be created as follows:

"Number places" = 15

"Number decimal places" = 14

c) Where are the rounding decimal places defined for the quantities and what effects does this have?

The rounding decimal places are defined in Customizing for the units of measurement via "Number of rounding decimals" (Transaction CUNI).

For materials with product units of measure, a verification of the posted quantities is carried out:

For 3 rounding decimal places, the one-to-one of the conversion of the quantity is checked in a base unit of measure into the product unit of measure (quantity in product unit of measure is rounded off to 3 decimal places) and back.

In addition, for less than 3 rounding decimal places, the quantity in the product units of measure may not have more decimal places than are determined by the rounding decimal places (quantity in product unit of measure is not rounded off).

For further details see section "One-to-one of the quantity conversion" further below.

Example 10: Examples for rounding decimals

The base unit of measure of a material is KG. Furthermore, the product units of measure PCS is used. You should make sure that the moved quantities always correspond to the complete piece.

You determine the number of rounding decimals per piece with 0.

For a batch with the piece weight 300 KG/PCS, a goods issue of more than 2800 KG (corresponds to 9.333 PCS) can no longer be posted; depending on the situation, an error message is generated or an error-free quantity (here: 2700 KG) is proposed.

d) Displayability of the conversion factor as a five-digit fraction

The conversion factor should always be one-to-one in a five-digit fraction.

This is at least always the case when the conversion factors have

a maximum of 5 places other than zero in sequence (significant places)

and

a maximum of 5 predecimal or 4 decimal places.

Conversion factors with more than 5 predecimal places can never be represented as a five-digit fraction (largest value = 99999/1 ).

In additon, there are more conversion factors that are displayable as five-digit fraction, however they do not fulfill these conditions. Nevertheless, this simple rule can be used as a criteria that corresponds to the format listed above without having to conduct another check (for example, from an external system).

Example 11:

Con.factor Significant places Pred.places Dec.places OK

12345.000 5 5 0 Yes

123456.000 6 6 0 No

1.1234 5 1 4 Yes

0.12345 5 0 5 ?

654,321 6 3 3 ?

Conversion factors which do not correspond to the conditions listed above should be adjusted through a function module. This must occur in relation to the the classification. For this, the ABAP functions CONVERT_TO_FRACT5 or MURC_ROUND_FOR_FRACT must be included in a variant function.

As a result, these functions return a divisor-foreign quotient which corresponds to the original conversion factor as exactly as possible. The difference between the two functions is that the MURC_ROUND_FOR_FRACT always returns quotients which correspond to a finite decimal fraction, whereas the CONVERT_TO_FRACT5 can find a better approach, however, which generally results in a cyclic (and thus no finite) decimal fraction.

An approach with the MURC_ROUND_FOR_FRACT must always occur exactly, if a unit of measure is in the denominator of the conversion factor which has less than 3 rounding decimal places or is the base unit of measure and which should be posted in multiples of 10 ** (- <Number of the rounding decimal places>): A classic example of this are all (countable) units of measure in whole numbers. Furthermore, the unit of measure in the numerator must be the base unit of measure, or a product unit of measure with less than 3 rounding decimal places.

For product units of measure with 3 rounding decimal places, you can suppress the check to the displayability of the decimal conversion factor as a five-digit numerator and denominator through Note 435144.

Remark:

All five-digit numerators and denominators can be mapped one-to-one to 15-digit decimal fractions. This means that not the display of conversion factors as maximally 15-digit decimal fractions restricts the accuracy of quantity conversions but the number of places of denominators and numerators.

e) One-to-one of the quantity conversion

The one-to-one of the quantity conversion means that the conversion of a quantity into another unit of measure and the calculation back into the original unit of measure deliver the same result. This is checked during the conversion of product units of measure into the base unit of measure. If the one-to-one is not given, the system will issue message XU056.

If the specification of the base unit of measure, the rounding decimal places for the product units of measure and the format of the conversion factors were adjusted correctly and if the quantity is a multiple of the increment, then this message should not appear (for the calculation of the increment, see function module documentation for the ABAP functions MURC_GCD and MURC_QUANTITY_CHECK or Note 519561).

You can restrict this check to a certain unit of measure with a BAdI (see Note 612945).

f) The definition of the conversion factor is converted as a relationship from the base unit of measure for product unit of measure or vice versa.

The examples assume that the conversion factor is defined as the "ratio base unit of measure to product unit of measure".

If the base unit of measure and the product unit of measure have the same amount of rounding decimal places (particularly those that are whole numbers), then you should divide the smaller unit of measure into the numerator (for example, piece/cardboard box).

If the product unit of measure has less than 3 rounding decimal places, and the number of the rounding decimal places differs from the base unit of measure, then you should divide the unit of measure that has fewer rounding decimal places into the denominator (for example, KG/PCS).

If the product unit of measure with 3 rounding decimal places is defined, then it is not important around how much the quotient is defined.

3. Using dependency and variant functions for setting conversion factors in classification

The dependency assigned to a batch class is always used when an object is classified in the batch class.

Maintenance of a plan conversion factor in the portion/product quantity view of the material master technically also corresponds to a classification of object MARM_WS. For this reason, the plan conversion factor you entered manually should not be set via dependency at the same time. Otherwise, message LB 109 may be displayed, and the entered plan conversion factor cannot be saved.

In variant functions, you can use function module CUDB_GET_TYPE to determine the object type of the currently classified object via the ITYPE. Make sure that no dependency setting the conversion factor is used for object type MARM_WS.

Header Data

Release Status: Released for Customer

Released on: 24.06.2004 10:57:13

Priority: Recommendations/additional info

Category: Consulting

Primary Component: LO-BM-UOM Batch-Specific Units of Measure

Secondary Components: LO-BM-AI Active Ingredients

MM-IM-GF-AUM Alternative Units of Measure

BC-SRV-ASF-UOM Unit Management

Affected Releases

JL23
Active Contributor
0 Kudos

Enter just:

http://service.sap.com/

on top right is a hyperlink "New User? Register here! "

click it an follow instruction, or ask your basis guys.

Alternativly, you can try Transaction code SNOTE in your SAP.

With CTRL+F8 you can download the note and read it if this access is open to you.

Or ask a colleque to download it for you.