GetItemUoMConversionFactor

Get Item UoM Conversion Factor

Major Business Rule

Object Name: B4000520

Parent DLL: COPBASE

Location: Client/Server

Language: C

Functional Description

Purpose

This function retrieves the unit of measure conversion factors for an item.  It retrieves the 

conversion between the From and To units of measure and can calculate the quantity to the unit of measure 

specified for the item.


Setup Notes and Prerequisites

The Branch (MCU), From UOM (UOM), To UOM (UOM) and Short Item Number (ITM) are required input 

parameters.  The Branch is only used if the Distribution Constants Flag (F4009) has been set to indicate 

conversions are performed at the Item and Branch level.  


Conversion between the FROM uom and the To uom; the From uom and the Primary uom and the TO uom and 

the Primary uom are always calculated.  In order to calculate other conversions (secondary, pricing, 

etc.), a flag must be set on. 


If the Potency Mode (GFLG) is an 'S' or 'K', standard potency is used.  Otherwise, if the lot is 

blank, use standard potency.  If the lot is not blank, the lot potency from the lot master is used.  Sales 

Order Processing needs to pass SDCOMM into this field and Purchase Order Processing needs to pass an 

'S'.


Technical Specification



Initialize all the quantity fields to zero.  These are :

QuantityToConvert

QuantityConvertedToPrimary

QuantityConvertedToSecondary

QuantityConvertedToPurchasing

QuantityConvertedToPricing

QuantityConvertedToShipping

QuantityConvertedToWeight

QuantityConvertedToVolume


Initialize the conversion factor fields to 1.0.  

These are :

ConversionFactorFrom_to_To

ConversionFactorFrom_to_Primary

ConversionFactorTo_to_Primary



If InventoryInterfaceFlag is blank then set the value to 'Y'


Call the business function GetDistributionConstants to 

retrieve the system constants flags.  Retrieve the value for

BUMC (Process Units of Measure by Branch) flag.


For Inventory interface flag equal to 'D', 'Y', or B.


If UnitOfMeasureToPrimary is blank and ShortItemNumber is not blank, retrieve 

UnitOfMeasureToPrimary and StandardUnitsofMeasure (TFLA) from F4101 table (Item Master).


For  each of the following cases DO STEP A :

Conversion 'FROM UoM' to 'TO UoM'

If UnitOfMeasureToPrimary is not blank then process conversion 'FROM UoM' to Primary UoM.

If ConversionToSecondary flag is on the process conversion 'FROM' UoM to Secondary UoM.

If ConversionToPurchasing flag is on the process conversion 'FROM' UoM to Purchasing UoM.

If ConversionToPricing flag is on the process conversion 'FROM' UoM to Pricing UoM.

If ConversionToShipping flag is on the process conversion 'FROM' UoM to Shipping UoM.

If ConversionToWeight flag is on the process conversion 'FROM' UoM to Weight UoM.

If ConversionToVolume flag is on then process conversion 'FROM' UoM to Volume UoM.


Step A.

Check stack of conversion factors for previously retrieved conversions to see if the one needed 

exists.

If it exists then use the conversion factor from the stack and go to retrieve next Unit of Measure

Also check the stack for the inverse conversion factor and use it if it exists.

(Note the stack is to cut down on the number of data retrieval fetches that are made in the program 

to increase the efficency of the program).


If the Short Item Number is not equal to zero then 


     If TFLA (Standard Units of Measure Conversion) not equal '1'


If not go to record retrieval from F41002 as follows :

If the 'TO' UoM is equal to items primary UoM (UOM1) then

Retrieve conversion factor from F41002 using Branch/Plant(optional), Item number and 
'FROM' UoM from the file F41002.  Use the field Conversion Factor To Primary for retrieved 

conversion factor

Add the Conversion Factor to Primary to the ConversionFactorFrom_to_Primary field.  Set 

off ConversionToPrimary flag.

If the 'TO' UoM is not equal to the primary then :
Retrieve conversion factor from F41002 using Branch/plant(optional), Item Number, 'FROM' 
Unit of Measure, 'TO' Unit of Measure to retrieve the conversion factor from the file 

F41002.


If no conversion factor has been found
Switch the 'FROM' Unit of Measure and 'TO' Unit of Measure around and go through step A 
again.  If the conversion factor is found with the switched Units of Measure then inverse 

the conversion factor before use.


If TFLA (Standard Units of Measure Conversion) equals '1'

OR the ShortItemNumber is zero 

OR no conversion factor has been found in F41002 then

use the existing business function GetStandardUoMConversionFactor (B4000390) to retrieve the 
conversion factor from the standard UoM file (F41003).


UnitOfMeasure<=From Unit Of Measure

RelatedUnitOfMeasure<=Primary Unit Of Measure

QuantityRelatedToUOM<=1

DisplayErrors<=N

ConversionFactor=>From to Primary Conversion Factor


if ( To UOM is not equal to Primary UOM)

GetStandardUOMConversionFactor must be called two more times.


 UnitOfMeasure<=To Unit Of Measure

RelatedUnitOfMeasure<=Primary Unit Of 

Measure

QuantityRelatedToUOM<=1

DisplayErrors<=N

ConversionFactor=>To UOM to Primary UOM Conversion 

Factor


UnitOfMeasure<=From Unit Of 

Measure

RelatedUnitOfMeasure<=To Unit Of Measure

QuantityRelatedToUOM<=1

DisplayErrors<=N

ConversionFactor=>From_UOM to To_UOM Conversion 

Factor

end


Save the 'FROM' Uom and 'TO' UoM conversion factor found in stack.


If no conversion factor is found then  set CONTINUE_GBR and error message 0269.

Calculate the extended quantities for each of the requested units of measure.

QuantityToConvert = Conversion Factor 'FROM' Uom -> 'TO' UoM * QuantityToConvert

QuantityConvertedToPrimary = Conversion Factor 'FROM UoM -> Primary UoM * QuantityToConvert.

If ConvertToSecondary is ON

QuantityConvertedToSecondary = Conversion Factor 'FROM UoM -> Secondary UoM  

* QuantityToConvert

If ConvertToPurchasing is ON

QuantityConvertedToPurchasing = Conversion Factor 'FROM' UoM -> Purchasing UoM

 *  QuantityToConvert

If ConvertToPricing is ON

QuantityConvertedToPricing = Conversion Factor 'FROM' UoM -> Pricing UoM

 *  QuantityToConvert

If ConvertToShipping is ON

QuantityConvertedToShipping = Conversion Factor 'FROM' UoM -> Shipping UoM

 *  QuantityToConvert

If ConvertToWeight is ON

QuantityConvertedToWeight = Conversion Factor 'FROM' UoM -> Weight UoM

 *  QuantityToConvert

If ConvertToVolume is ON

QuantityConvertedToVolume = Conversion Factor 'FROM' UoM -> Volume UoM

 *  QuantityToConvert


For Inventory interface flag equal to 'A' or 'N'.

These are for non-stock line types.


The following return fields are zeroised for non-stock items

Quantity in Secondary Unit of Measure

Quantity in Purchasing Unit of Measure

Quantity in Pricing Unit of Measure

Quantity in Shipping Unit of Measure

Quantity in Weight Unit of Measure

Quantity in 100 Weight Unit of Measure

Quantity in Volume Unit of Measure


If 'FROM' and 'TO' Unit of Measure are equal then force the following to 1.0.

Conversion factor

Conversion factor 'FROM' UoM ->  primary

Conversion factor  'TO' Uom ->  primary


The conversion factor is retrieved directly from the Standard Unit of Measures file F41003.  (Note 

that a business function for this already exists called GetStandardUoMConversionFactor).


Retrieve Special Handling Codes for Units of Measure if doing potency processing

If OT1Y equals 'Y'

If the previous From Unit of Measure is different than the current From Unit of Measure

OR the previous To Unit of Measure is different than the current To Unit of Measure

Retrieve Special Handling Codes for the From and o Unit of Measure

If the previous Item Number is different than the current Item Number

Retrieve Special Handling Codes for UOM1, UOM2, UOM3, UOM4, UOM6, 

UWUM, UVM1 and the From and To Unit of Measure.


Retrieve the Special Handling Code from the F0005 from the SPHD field for

SY = '00  '

RT = 'UM'


Store the first column of the Special Handling Code in a field for potency value

Store the second column of the Special Handling Code in a field for bulk 

value


Save the current From, To and Item Number


Convert Potency

If potency mode (GFLG) equals 'S' or 'K'

Potency = STDP

else

/* If lot number is blank, use standard potency passed in.

If LOTN equals blanks

Potency = STDP

else

/* Retrieve lot potency from Lot Master

Call GetLotMasterByLotNumber(B4000610) with parms as follows:

Lot NumberLot Number

Short Item NumberShort Item Number

Branch/PlantBranch/Plant

Return: Lot Potency (LOTP)


If record found, 

Potency = LOTP


Potency = Potency / 100

If Potency equals zero, go to bottom of potency processing


/* From potent/To not potent and To potency/From not potent for Quantity TO UOM

If Converting From to To

If From UOM is potent

AND To UOM is not potent

Quantity To UOM = Quantity To UOM / Potency

Conversion Factor = Conversion Factor / Potency

If To UOM is potent

AND From UOM is not potent

Quantity To Uom = Quantity To UOM * Potency

Conversion Factor = Conversion Factor * Potency


/* From potent/Primary not potent and Primary potent/From not potency for Quantity in 

Primary

If Converting From to Primary

OR to Secondary, Purchasing, Pricing, Shipping, Weight, Hundred Weight or Volume

If From UOM is potent

AND Primary UOM is not potent

Primary Quantity  = Primary Quantity / Potency

Conversion Factor From to Primary  = 

Conversion Factor From to Primary / Potency

If Primary UOM is potent

AND From UOM is not potenct

Primary Quantity = Primary Quantity * Potency

Conversion Factor From to Primary = 

Conversion Factor From to Primary * Potency


/* To potent/Primary not potent and Primary potent/To not potent

If Converting To to Primary

If To UOM is potent

AND Primary UOM is not potent

Conversion Factor To to Primary  = Conversion Factor To to Primary / 

Potency

If Primary UOM is potent

AND To UOM is not potenct

Conversion Factor To to Primary = Conversion Factor To to Primary * 

Potency


/* From potent/Secondary not potent and Secondary potent/From not potent

If Converting to Secondary

If From UOM is potent

AND Secondary UOM is not potent

Quantity in Secondary = Quantity in Secondary / Potency

If Secondary UOM is potent

AND From UOM is not potenct

Quantity in Secondary = Quantity in Secondary * Potency


/* From potent/Purchasing not potent and Purchasing potent/From not potent

If Converting to Purchasing

If From UOM is potent

AND Purchasing UOM is not potent

Quantity in Purchasing = Quantity in Purchasing / Potency

If Purchasing UOM is potent

AND From UOM is not potent

Quantity in Purchasing = Quantity in Purchasing * Potency


/* From potent/Pricing not potent and Pricing potent/From not potent

If Converting to Pricing

If From UOM is potent

AND Pricing UOM is not potent

Quantity in Pricing = Quantity in Pricing / Potency

If Pricing UOM is potent

AND From UOM is not potent

Quantity in Pricing = Quantity in Pricing * Potency


/* From potent/Weight not potent and Weight potent/From not potent

If Converting to Weight 

OR Converting to 100 Weight

If From UOM is potent

AND Weight UOM is not potent

Quantity in Weight = Quantity in Weight / Potency

Quantity in 100 Weight = Quantity in 100 Weight / Potency

If Weight UOM i'1a 

Data Structure

D4000520 - Get Item UoM Conversion Factor


^

Parameter NameData ItemData TypeReq/OptI/O/Both
szBranchPlantMCUcharNONENONE


szFromUnitOfMeasureUOMcharNONENONE

A user defined code (00/UM) that indicates the quantity in which to express an inventory item, for example, CS (case) or BX (box).

szToUnitOfMeasureRUMcharNONENONE

A code (UDC table 00/UM) that indicates a secondary unit of measure.

mnQuantityToConvertQTYMATH_NUMERICNONENONE

The number of units associated with an asset.

cInventoryInterfaceFlagIVIcharNONENONE

A code that identifies the type of interface to the Inventory Management system. Valid values are:    Y The dollar or unit value of any activity 
containing this line type will be reflected in inventory. The system also edits the item that you enter to ensure that it is a valid item. Y is the 
default.    A The system recognizes the number that you enter as a G/L account number. The system uses this code in purchasing only.    B The 
system performs edits when using format 4 in purchase order entry.        The system retrieves price data from the inventory tables, but does not 
update the quantity on the purchase order. This code is valid only when you have set the G/L Interface field to Y (yes). Budget checking is 
fully functional when you use this interface code.    D The item in this line is an inventory item that will not affect availability or quantities.    N The 
item is not an inventory item. To verify whether the item exists in the Item Master file, use Inventory Interface N in conjunction with the flag, Edit 
the Item Master for Non-Stock Items.

mnConversionFactorFromToPrimCONVMATH_NUMERICNONENONE

The factor that the system uses to convert one unit of measure to another unit of measure.

mnConversionFactorFrom_to_ToCONVMATH_NUMERICNONENONE

The factor that the system uses to convert one unit of measure to another unit of measure.

mnConversionFactorTo_to_PrimarCONVMATH_NUMERICNONENONE

The factor that the system uses to convert one unit of measure to another unit of measure.

mnQuantityConvertedToPrimaryQTYMATH_NUMERICNONENONE

The number of units associated with an asset.

cConvertToSecondaryCVOBcharNONENONE

Conversion object (Y,N).

mnQuantityConvertedToSecondaryQTYMATH_NUMERICNONENONE

The number of units associated with an asset.

cConvertToPurchasingCVOBcharNONENONE

Conversion object (Y,N).

mnQuantityConvertedToPurchasinQTYMATH_NUMERICNONENONE


^

cConvertToPricingCVOBcharNONENONE

Conversion object (Y,N).

mnQuantityConvertedToPricingQTYMATH_NUMERICNONENONE

The number of units associated with an asset.

cConvertToShippingCVOBcharNONENONE

Conversion object (Y,N).

mnQuantityConvertedToShippingQTYMATH_NUMERICNONENONE

The number of units associated with an asset.

cConvertToWeightCVOBcharNONENONE

Conversion object (Y,N).

mnQuantityConvertedToWeightQTYMATH_NUMERICNONENONE

The number of units associated with an asset.

cConvertToVolumeCVOBcharNONENONE

Conversion object (Y,N).

mnQuantityConvertedToVolumeQTYMATH_NUMERICNONENONE

The number of units associated with an asset.

cPotencyModeGFLGcharNONENONE

A cash/accrual flag, which controls whether an expense participation class relates to ledger type AA (accrual) or AZ (cash). If the field 
contains C, the class relates to ledger type AZ. With any other code, the class relates to ledger type AA.

szLotNumberLOTNcharNONENONE

A number that identifies a lot or a serial number. A lot is a group of items with similar characteristics.

cPotencyControlOT1YcharNONENONE

A code that indicates whether you control the item by potency.

mnStandardPotencySTDPMATH_NUMERICNONENONE

The percentage of active ingredients normally found in an item.

szErrorMessageIDDTAIcharNONENONE

A code that identifies and defines a unit of information. It is an alphanumeric code up to 8 characters long that does not allow blanks or 
special characters such as %, &, or +. You create new data items using system codes 55-59. You cannot change the alias.

cSuppressErrorMsgEV01charNONENONE

An option that specifies the type of processing for an event.

cPotencyTypeEV01charNONENONE

An option that specifies the type of processing for an event.

mnShortItemNumberITMMATH_NUMERICNONENONE

An inventory item number. The system provides three separate item numbers plus an extensive cross-reference capability to other item 
numbers (see data item XRT) to accommodate substitute item numbers, replacements, bar codes, customer numbers, supplier numbers, and 
so forth. The item numbers are as follows:   o Item Number (short) - An eight-digit, computer-assigned item number     o 2nd Item Number - The 
25-digit, free-form, user defined alphanumeric item number     o 3rd Item Number - Another 25-digit, free-form, user defined alphanumeric item 
number

cUOMByBranchBUMCcharNONENONE

A code that indicates how the system uses the branch/plant within the Item Specific Unit of Measure Conversion tables. Valid values are:    Y 
The system displays the item-specific conversion table when you add an item to a specific branch/plant.    N The system displays the 
item-specific conversion table for all branch/plants from the Item Master table.

szUOMToPrimaryUOMcharNONENONE

A user defined code (00/UM) that indicates the quantity in which to express an inventory item, for example, CS (case) or BX (box).

szUOMToSecondaryUOMcharNONENONE

A user defined code (00/UM) that indicates the quantity in which to express an inventory item, for example, CS (case) or BX (box).

szUOMToPurchasingUOMcharNONENONE

A user defined code (00/UM) that indicates the quantity in which to express an inventory item, for example, CS (case) or BX (box).

szUOMToPricingUOMcharNONENONE

A user defined code (00/UM) that indicates the quantity in which to express an inventory item, for example, CS (case) or BX (box).

szUOMToWeightUOMcharNONENONE

A user defined code (00/UM) that indicates the quantity in which to express an inventory item, for example, CS (case) or BX (box).

szUOMToVolumeUOMcharNONENONE

A user defined code (00/UM) that indicates the quantity in which to express an inventory item, for example, CS (case) or BX (box).

szUOMToShippingUOMcharNONENONE

A user defined code (00/UM) that indicates the quantity in which to express an inventory item, for example, CS (case) or BX (box).

szStandardUOMConversionTFLAcharNONENONE

Allows you to bypass the item-specific unit of measure and use the standard unit of measure. Valid values are:    blank Use the item-specific 
unit of measure    1       Bypass the item-specific unit of measure and use the standard unit of measure

mnQuantityConvertedFromtoToQTYMATH_NUMERICNONENONE

The number of units associated with an asset.

cExcludeFlagEXSOcharOPTNONE

An option that indicates whether a particular unit of measure is invalid for a sales order.  Values are: Blank, N, or 0 The System includes the 
UOM in SO 1 or Y The System excludes the UOM from SO 

Related Functions

B4000390 Get Standard Unit of Measure Conversion Factor
B4000530 Get Distribution Constants
B9800150 Update and Right Justify User Defined Codes Value

Related Tables

F0005 User Defined Codes
F41002 Item Units of Measure Conversion Factors
F4101 Item Master
F4108 Lot Master