About refresh on WBP
About refresh of unit please check the page below :
Unit of measure / Quantity unit / UOM -> RSIMPCUST
Conversion Unit C_MATNR2 - UOMCMAT2 - Specific rules
The recursive transformation TSRF : UOMCMAT2 -> UOMCMAT2 (recursive) add conversion factors to missing units : KG / LB / TO / VKG / VTN
Program Steps
Generate a matrix of unit per LogSys/Material/BuoM
KG Unit KG Nom KG Dén TO Unit TO Nom TO Dén 1KG Unit 1KG Nom 1KG Dén ... WP1/Material 1/KG KG 1.000 1.000 TO 1.000.000 1.000 ... WP1/Material 2/KG KG 1.000 1.000 1KG 1.000 277 ... - Add KG unit
- Read TO unit if available
- Read LB unit if available
- Add TO unit
- Read KG unit if available
- Read LB unit if available
- Add LB unit
- Read KG unit if available
- Read TO unit if available
- Add VKG unit
- Read by priority VTN > 1KG > 1TN > KGW > TOP > KRE > KG > TO if available
- Add VTN unit
- Read by priority VKG > 1KG > 1TN > TOP > KGW > KRE > KG > TO if available
Units and Conversion exit
A Unit has only one internal code and is corresponding to one or more external code (country specific display and other reasons ...)
For example :
- KGW (Internal) is corresponding to KAI / KMA / KGR ... (External)
- TOP (Internal) is corresponding to AIT / ... (External)
Only the Internal code need to be check during the process.
Example of conversion bloc.
Legend:
- GREEN : Current unit to add, don't change in a global IF.
- RED : Unit to check if available, change at each IF/ELSEIF
**** Add VTN
IF <FS_MAT_UNT>-unit_VTN IS INITIAL.
l_SOURCE_PACKAGE-UNIT = 'VTN'. → Initialize the unit to add
l_SOURCE_PACKAGE-record = lv_tabix + 1. → Change the record number
IF <FS_MAT_UNT>-unit_VKG IS NOT INITIAL. → Check if the corresponding Unit is filled in the matrix
l_SOURCE_PACKAGE-uomz1d = <FS_MAT_UNT>-uomz1d_VKG * 1000. → Nominator (* factor if necessary)
l_SOURCE_PACKAGE-uomn1d = <FS_MAT_UNT>-uomn1d_VKG. → Denominator (* factor if necessary)
APPEND l_SOURCE_PACKAGE TO SOURCE_PACKAGE. → Append in Result Package
<FS_MAT_UNT>-UNIT_VTN = l_SOURCE_PACKAGE-UNIT. → Update the matrix
<FS_MAT_UNT>-uomz1d_VTN = l_SOURCE_PACKAGE-uomz1d. → Update the matrix
<FS_MAT_UNT>-uomn1d_VTN = l_SOURCE_PACKAGE-uomn1d. → Update the matrix
ELSE/ENDIF. → Next unit in the priority list or end of process
SKU vs RU (VKG)
SKU = Stock-keeping unit, a unique identifier for each distinct product and service that can be purchased / sales in business. It bases on material master
Function Module Z_MD_CONVERT_MATERIAL_UNIT3
Material unit conversion in ABAP code can be handled by two Function Modules.
Z_MD_CONVERT_MATERIAL_UNIT retrieving alternative units without source system (0LOGSYS), based on ODS Object ODS_MARM.
Z_MD_CONVERT_MATERIAL_UNIT3 retrieving alternative units with source system (0LOGSYS), based on ODS Object UOMCMAT2.
Do not use Z_MD_CONVERT_MATERIAL_UNIT2 anymore in new ABAP code, since it is a previous uncomplete version of the Z_MD_CONVERT_MATERIAL_UNIT3.
This previous version can still be found anyway in a lot of ABAP code, as long as the Materials are not dealing with different alternative units in several source systems.
Function Module Logic
Same logic is used in both Function Modules.
Source unit is first converted into Material Base Unit of Measure, and then result is converted into target unit if different from Base Unit.
Statics variables are used to keep Material already processed across several calls of FM, preventing new DB access to get conversion factors.
=> This is where inconsistency is noticed in Z_MD_CONVERT_MATERIAL_UNIT2 with System not taken into account when checking Material already processed.
(Check reference NGC20220308 for updated code in Z_MD_CONVERT_MATERIAL_UNIT3)
Chronology of process :
1. Convert the input Unit in Basic UoM according to logic below
1. Conversion factors have already been determined for Material in last call
2. Else search for Material conversion factors from buffer table
3. Else determine data from the DB
1. Search first with the last Material read (small buffer)
2. Else try it in all Material processed (large buffer)
3. Else read valid Mat Units from UOMCMAT2 for the Material/System (Z_MD_CONVERT_MATERIAL_UNIT3), or read valid Mat Units from ODS_MARM for the Material (Z_MD_CONVERT_MATERIAL_UNIT).
4. Else read all units from T006 table to get conversion factor from the Material Base UOM into the System International Unit of the same Dimension.
2. Convert the Basic UoM into target unit (if different from Base UoM) according to logic below.
1. Conversion factors have already been determined for Material in last call
2. Else search for Material conversion factors from buffer table
3. Else determine data from the DB
1. Search first with the last Material read (small buffer)
2. Else try it in all Material processed (large buffer)
3. Else read valid Mat Units from UOMCMAT2 for the Material/System (Z_MD_CONVERT_MATERIAL_UNIT3), or read valid Mat Units from ODS_MARM for the Material (Z_MD_CONVERT_MATERIAL_UNIT).
4. Else read all units from T006 table to get conversion factor from the Material Base UOM into the System International Unit of the same Dimension.
Rounded Factors :
When the target unit is not the Basic UoM, and the conversion is done through the Basic UoM, it leads sometimes to a rounded factor used to convert from source unit to target unit.
This can raise differences between conversion done with the Function Module Z_MD_CONVERT_MATERIAL_UNIT3, and conversion done directly in a query with conversion types (RSUOM) where factor is not rounded.


