Sunteți pe pagina 1din 10

Units and rounding

14-07-13

Unit determination and Rounding


Version 1.01
(5. March-2004)

Markus Wolf

Units and rounding

14-07-13

Introduction........................................................................................................................3 ME21 (SAPMM06E)..........................................................................................................3


Base unit.......................................................................................................................................................3 Order unit......................................................................................................................................................3 Quantity........................................................................................................................................................3 Rounding.......................................................................................................................................................3 Conversion factor for order unit...................................................................................................................4 Weight and volume.......................................................................................................................................4 Points............................................................................................................................................................4 Price unit.......................................................................................................................................................4 Conversion factor for price unit....................................................................................................................4

ME21N (MEPO).................................................................................................................4
Base unit.......................................................................................................................................................4 Order unit......................................................................................................................................................4 Quantity........................................................................................................................................................5 Rounding.......................................................................................................................................................5 Conversion factor for order unit...................................................................................................................7 Weight and volume.......................................................................................................................................7 Points............................................................................................................................................................8 Price unit.......................................................................................................................................................8 Conversion factor for price unit....................................................................................................................8

Debugging...........................................................................................................................9
SAPMM06E.................................................................................................................................................9 MEPO...........................................................................................................................................................9

Open point..........................................................................................................................9 Notes....................................................................................................................................9 Appendix...........................................................................................................................10


Interesting fields.........................................................................................................................................10 Purchasing document..............................................................................................................................10 Inforecord...............................................................................................................................................10 Conditions...............................................................................................................................................10

Units and rounding

14-07-13

Introduction
The unit determination in purchasing is a bit complicated as the units used for ordering and the conversion factors can come from many sources. The main sources are the material master and the purchasing inforecord.

ME21 (SAPMM06E)
The sequence in which the different variables are determined is as follows:

Base unit
The base unit is retrieved from the material master. If there is no material in the current item, the unit stays empty (routine determine_lmein).

Order unit
At first it is checked if variable order units are allowed (material master, inforecord, sub-item). If a unit has been entered manually and variable order units are allowed, this unit is used. If not, the system tries to determine a unit automatically (routine determine_meins). For this the following documents are searched through for units: 1. Reference document (PO is copied to another PO) 2. Contract 3. Request for quotation 4. Purchasing requisition (order unit, if maintained) if variable order units are allowed 5. Purchasing inforecord 6. Purchasing requisition (order unit, if maintained) 7. Purchasing requisition (requisition unit) 8. Material master (order unit) 9. Material master (unit of issue) 10. Material master (base unit) 11. For service lines it is determined with the function MS_READ_UNIT

Quantity
To determine the quantity that will be used in the PO, we try to determine the quantity and the related unit from the document to which we are referring when creating the PO and then convert this quantity into the order unit (routine determine_menge). For this conversion we first check if a different conversion factor is defined in the inforecord, in a related customer order or a batch (routine unit_from_sd_batch) or in the customizing (e.g. the factor between kg and to). The order and the batch have priority over the inforecord. If such a factor is found, this conversion factor is used, if not the conversion factor is determined by the function ME_CONVERSION_BPRME that tries to get the factor from the material master.

Rounding
If we are entering new data, rounding is performed next (routine determine_round). This can change the quantity and the order unit. If a rounding happens and no one knows why, it is usually a good idea to check the following entries: Inforecord (Purchasing Organization Data 1) o Minimum quantity o Rounding Profile Material master (MRP1) o Minimum lot size 3

Units and rounding

14-07-13

o Rounding Profile o Rounding value Decimal places for rounding (in the customizing: General Settings -> Check units of measurement -> Units of measurement -> Details)

Conversion factor for order unit


After the units have been determined, the conversion factor is calculated (routine determine_umrez). It may be based on a related customer order, a batch given in the PO, a purchasing inforecord, the material master or the customizing for units.

Weight and volume


If the order unit is the same as in the reference document, contract or RFQ weight and volume are copied from there (routines determine_ntgew and determine_volum). If the order unit is the base unit, weight and volume are directly retrieved from the material master. If the order unit is some other unit, weight and volume are retrieved from the material master for the base unit and a recalculation is done by using the conversion factor.

Points
Points are used in for the calculation of rebates at the end of a period. The points are retrieved from the reference document, a RFQ, a contract or an inforecord (routine determine_anzpu).

Price unit
The price unit is initially filled with the order unit (if no value as been entered manually)(routine determine_bprme). It will be overwritten when the pricing is performed.

Conversion factor for price unit


The conversion factor is initially filled with 1 (if no value as been entered manually)(routine determine_bpumz). It will be overwritten when the pricing is performed.

ME21N (MEPO)
Base unit
The base unit is retrieved from the material master. If there is no material in the current item, the unit stays empty (routine mepo_item_fill_lmein).

Order unit
At first it is checked if variable order units are allowed (material master, inforecord, sub-item). If a unit has been entered manually and variable order units are allowed, this unit is used. If not, the system tries to determine a unit automatically (routine mepo_item_fill_meins). For this the following documents are searched through for units: 1. Reference document 2. Contract 3. Request for quotation 4. Purchasing requisition (order unit, if maintained) if variable order units are allowed 5. Purchasing inforecord 6. Purchasing requisition (order unit, if maintained) 4

Units and rounding 7. 8. 9. 10. 11. Purchasing requisition (requisition unit) Material master (order unit) Material master (unit of issue) Material master (base unit) For service lines it is determined with the function MS_READ_UNIT

14-07-13

Quantity
To determine the quantity that will be used in the PO, we try to determine the quantity and the related unit from the document to which we are referring when creating the PO and then convert this quantity into the order unit (routine mepo_item_fill_menge). For this conversion we first check if a different conversion factor is defined in the inforecord, in a related customer order or a batch or in the customizing (e.g. the factor between kg and to). The order and the batch have priority over the inforecord. If such a factor is found, this conversion factor is used, if not the conversion factor is determined by the function ME_CONVERSION_BPRME that tries to get the factor from the material master.

Rounding
If we are entering new data, rounding is performed next (routine mepo_item_fill_round). This can change the quantity and the order unit. If a rounding happens and no one knows why, it is usually a good idea to check the following entries: Inforecord (Purchasing Organization Data 1) o Minimum quantity o Rounding Profile Material master (MRP1) o Minimum lot size o Rounding Profile o Rounding value Decimal places for rounding (in the customizing: General Settings -> Check units of measurement -> Units of measurement -> Details) If rounding happens and this is ok in principle, but nobody understands the result: set a breakpoint in include LMPOEF65, form mepo_item_fill_round where the function module MD_SINGLE_ROUNDING is called. Check that the quantity right before the call (field ls_general-menge and ls_general-meinh) is what the user has entered. Keep in mind the qty right after the call (ls_results-lmenge and ls_results-logme, ls_results-menge and ls_results-meins). Set one more breakpoint where ME_PROOF_VARIABLE_ORDERUNIT is called (always inside mepo_item_fill_round). Two cases: 1) ME_PROOF_VARIABLE_ORDERUNIT comes back with sy-subrc = 0: if the result on the PO is what you can see in ls_results-lmenge and ls_results-logme -> forward the message to component LO-MD-QO 2) ME_PROOF_VARIABLE_ORDERUNIT comes back with sy-subrc ne 0: if the result on the PO is what you can see in ls_results-menge and ls_results-meins -> forward the message to component LO-MD-QO Rounding takes place just once and should be seen as a proposal from the system. As soon as rounding takes place the user will be informed about this by message ME 386 (customizable). If the user disagrees with the proposal, he can change the qty manually and there will be no more rounding afterwards. A second rounding for the same PO item can just take place if: the rounding profile has changed or the material has changed or an error came up during the last attempt to do rounding or 5

Units and rounding a held PO shall be saved.

14-07-13

Rounding can just take place if there has been entered a material for the PO item (no text lines, no services, ..) whereby the existence of an external material number (ekpo-ematn) is sufficient (it could be an MPN material for which rounding should be done).

analysis of the code for rounding


Rounding has been split into two subroutines: form mepo_item_fill_round (LMEPOF65) and form mepo_check_round (LMEPOF1X). This was necessary for reasons of message output. In the past rounding was done in mepo_item_fill_round and the message output was processed right afterwards in the same subroutine. But if message ME 386 had been configured as error message, there was an error message output during the filling phase of MEPO and this stopped all the filling process immediately. This is against the design (filling MUST be done fully, all the checks come afterwards), short dumps occurred in customers' systems. Solution: rounding is done in mepo_item_fill_round, the result of the rounding is stored in the internal table GT_ROUND_MEM and the message output based on the information in GT_ROUND_MEM is done in mepo_check_round. another internal table used in mepo_item_fill_round: GT_PREV_ROUND_ERR. This is used in order to keep in mind the last rounding attempt was not successful. When the program comes to mepo_item_fill_round the next time, rounding is tried again. mepo_item_fill_round does not do the rounding itself but just prepares the data and then calls function module MD_SINGLE_ROUNDING. MD_SINGLE_ROUNDING is not in our responsibility -> component LO-MD-QO. storage of rounding result in internal table GT_ROUND_MEM: there are different scenarios: MD_SINGLE_ROUNDING comes back with an exception: don't take over rounding results (fllag kz_no_take_over) and store the message of MD_SINGLE_ROUNDING for later output MD_SINGLE_ROUNDING has changed the input qty: check whether this is allowed (ME 386 configured as warning or as error message? ): if error: store the reasons for rounding for later output and don't take over rounding results (fllag kz_no_take_over) if warning: store the reasons for rounding for later output and take over rounding results If MD_SINGLE_ROUNDING comes back to us with the proposal to change the order unit of measure, we have to check whether this is allowed -> variable order units of measure allowed for the current material? If that's ok, we take over the new order UOM, otherwise we keep the originally entered order UOM and take over the new qty converted to the the originally entered order UOM. One special scenario: PO has not been saved but just put on hold. We allow to put on hold even when rounding comes back with an error. When, afterwards, the user tries to save the PO we have to take care this is just allowed if rounding is fine. For that reason we simulate rounding again, don't take over the result but evaluate if there have been any errors. In case there have been no errors we avoid to output any rounding warnings again (flag l_kz_no_message_output).

customizing
Logistics General->Quantity Optimizing and Allowed Logistics Units of Measure, 6

Units and rounding

14-07-13

maintain rounding profiles: you can maintain static and dynamic rounding profiles, per plant or plant independent. As of release 4.7 there is another customizing issue: Control for Quantity Optimizing (same path as above). You can create control profiles which define on a very detailed level which activities/functionalities are desired or should not be done during the rounding process. This is a much clearer way of definition as it was done before (by material master data and info record data which can overlap). The control profile can be assigned to the calling application and transaction code.

user-exit
We will never manage to satisfy all of our customers' wishes in terms of rounding. For that reason there is a user-exit integrated into MD_SINGLE_ROUNDING where the customer can implement his own rounding mechanism -> see note 301105.

experience with OSS messages


Some customers complain there is a difference in the result of rounding depending on whether they enter the vendor immediately or they leave the vendor field space at the beginning. This works as designed, LO-MD-QO wanted to create an information note for this. As long as the vendor is missing some important information is missing to the program. E.g. we still don't know whether the PO is going to be a stock transport (could become a cross company) or not. In this situation MD_SINGLE_ROUNDING bases on the most general information available (MARA level) for the material and ignores any other data (MARC, EINA/EINE, ..). If such an OSS message comes in -> forward to LO-MD-QO.

Conversion factor for order unit


After the units have been determined, the conversion factor is calculated (routine mepo_item_fill_umrez). It may be based on a related customer order, a batch given in the PO, a purchasing inforecord, the material master or the customizing for units. In certain cases the conversion factors are taken over from a related sales order (PO has been created with ref. to a PR, PR has been created automatically during creation of the sales order). In the sales order there is possibility to define own conversion factors. Please note, in ME21N, the conversion factors are just taken over from the sales order if active ingredients handling or product unit of measure handling is active (in this case VBAP-KZFME is not initial). This is a difference to ME21 where you always take over the conversion factors from the sales order. Note 556013 describes how a customer can change the code in order to have the same behaviour in ME21N as in ME21 or vice versa. A similar rule applies if there is no sales order linked but you use a material number with batch handling and there have been defined special conversion factors for the batch. They are just taken over in case the current UOM is subject to proportion unit or product unit of measure (MARM-KZWSO).

Weight and volume


If the order unit is the same as in the reference document, contract or RFQ weight and volume are copied from there (routines mepo_item_fill_ntgew and mepo_item_fill_volum). If the order unit is the base unit, weight and volume are directly retrieved from the material master. If the order unit is some other unit,

Units and rounding

14-07-13

weight and volume are retrieved from the material master for the base unit and a recalculation is done by using the conversion factor.

Points
Points are used in for the calculation of rebates at the end of a period. The points are retrieved from the reference document, a RFQ, a contract or an inforecord (routine mepo_item_fill_anzpu).

Price unit
The price unit is initially filled with the order unit (if no value as been entered manually)(routine mepo_item_fill_bprme). It will be overwritten when the pricing is performed.

Conversion factor for price unit


As it is possible in the ME21N to change a lot of data that could not be changed in the old transaction, the routine mepo_item_fill_bpumz is a bit more complicated that the determine_bpumz. The pricing only determines the conversion factor correctly from the batch if the factor already present in the KONV is empty. This is initially the case, but not if the batch is changed afterwards. In this case we have to calculate the factor and pass it into the pricing. Normal way how conversion factors for price units are determined: Per default the conversion factors are set to 1. After pricing has been processed and all the conditions are known, the conversion factor is taken over from the very first condition which has been flagged as base price (or let's better say the corresponding condition TYPE has been flagged as base price). Please note some customers complain the conversion factors are not taken over from a certain condition. Usually, in this case the corresponding condition type has not been flagged as base price -> consulting. How to find out whether condition type has been flagged as base price: OLME, conditions->define price determination process->define condition types, define condition type, look for the right condition type and double click, in the subscreen 'control data 1' you will see the field 'cond. category', this field must have value 'H' for base price. corresponding code for take over of conversion factors for price unit: MM06EFKO_PREISFINDUNG_UEBERNAH:

FORM PREISFINDUNG_UEBERNAHME. READ TABLE TKOMV WITH KEY KPOSN = EKPO-EBELP BINARY SEARCH. "@109886 IF SY-SUBRC EQ 0. "@109886 DATA: L_TABIX LIKE SY-TABIX. "@109886 L_TABIX = SY-TABIX - 1. "@109886 DO. "@109886 L_TABIX = L_TABIX + 1. "@109886 READ TABLE TKOMV INDEX L_TABIX."@109886 IF ( SY-SUBRC NE 0 ) OR ( TKOMV-KPOSN NE EKPO-EBELP )."@109886 EXIT. "from do"@109886 ENDIF. "@109886 CHECK ( TKOMV-KNTYP EQ 'H' OR TKOMV-KNTYP CA 'GST' )."@109886

^^^^^^^^^^^^^^^^^^^^^

if this is not the case -> game over


.
EKPO-NETPR = F1 = KOMP-NETPR. IF KOMP-KMEIN EQ TKOMV-KMEIN. "111466 EKPO-BPUMZ = TKOMV-KUMNE. <<<<<<<< take over from the EKPO-BPUMN = TKOMV-KUMZA. <<<<<<<< condition ENDIF. "111466

Units and rounding

14-07-13

Debugging
If the behaviour of the quantity conversion/unit determination is somehow suspicious and cannot be easily explained, its a good idea to set breakpoints before the affected routines (especially the rounding-routine) and see where the values get strange. If the rounding from within MD_SINGLE_ROUNDING does not work correct, the message should be forwarded to the component LO-MD-QO.

SAPMM06E
In SAPMM06E the breakpoint should be set in NEUE_POS_ANFRAGE, NEUE_POS_BESTELLUNG or NEUE_POS_RAHMENVERTRAG before calling DETERMINE_LMEIN.

MEPO
In the function-group MEPO the breakpoint should be set in MEPO_ITEM_FILL before calling the routine MEPO_ITEM_FILL_LMEIN.

Open point
There is still an open point at the moment concerning conversion-factors defined in SD-orders/batches in combination with rounding as the rounding function MD_SINGLE_ROUNDING does currently not handle these.

Notes
Too many to count. Rounding: 401437 386240: User Exit in rounding function 303613 Handling of batches: 490331 390242 Redesign quantity conversion: 357864 350006 339057 338457 322391 321862 315310 313068 309124 308526 306980 306070 301550 300799 187511 9

Units and rounding

14-07-13

Appendix
Interesting fields Purchasing document
In the purchasing document we have the following fields: EKPO-MEINS: order unit EKPO-BPRME: price unit EKPO-LMEIN: base unit EKPO-UMREZ, EKPO-UMREN: conversion from order unit to base unit EKPO-BPUMZ, EKPO-BPUMN: conversion from order unit to price unit

If you want to calculate the ordered quantity in base unit: X = EKPO-MENGE * EKPO-UMREZ / EKPO-UMREN If you want to calculate the ordered quantity in price unit: X = EKPO-MENGE * EKPO-BPUMZ / EKPO-BPUMN

Inforecord
In the inforecord we have fields in EINA and EINE: EINA-MEINS: order unit EINA-LMEIN: base unit EINA-UMREZ, EINA-UMREN: conversion from order unit to base unit EINE-BPRME: price unit EINE-BPUMZ, EINE-BPUMN

If you want to convert a quantity from order unit into base unit: X = Y * EINA-UMREZ / EINA-UMREN If you want to convert a quantity from order unit into price unit: X = Y * EINE-BPUMZ / EINE-BPUMN

Conditions
In the table KONP we have the condition unit (whoch usually is the same as our price unit) and a field that is called base unit but really contains our order unit: KONP-KMEIN: condition unit (usually our price unit) KONP-MEINS: order unit (even if it is called base unit) KONP-KUMZA, KONP-KUMNE: conversion between KMEIN and MEINS

If you want to convert a quantity from condition unit into the order unit X = Y * KONP-KUMZA / KONP-KUMNE

10

S-ar putea să vă placă și