Unit Conversion:
UnitOfMeasureConverter_Product is product specific unit conversion. It lookups defined conversions in the following order:
- Use direct product-specific conversion, if one exists.
- Use a chain of two product-specific conversions through one base unit of measure, if one exists.
- Use a chain of product-specific conversions through two base units of measure, if one exists.
- Use a chain of one product-specific and one standard conversions through one base unit of measure, if one exists.
- Use a chain of product-specific or standard conversions through two base units of measure, if one exists.
- Execute the calculation algorithm for the standard conversions.
Meanwhile, UnitOfMeasureConverter::convert is just a wrap method that will call UnitOfMeasureConverter_Product if ProductId is provided. If no ProductId specify, it just do standard conversion.
static
void
Job_UnitConversion(Args _args)
{
#define.itemId(
'M0018'
)
//Method one
UnitOfMeasureConverter_Product unitConverter = UnitOfMeasureConverter_Product::construct();
unitConverter.parmProduct(InventTable::find(#itemId).Product);
unitConverter.parmFromUnitOfMeasure(UnitOfMeasure::unitOfMeasureIdBySymbol(
'kg'
));
unitConverter.parmToUnitOfMeasure(UnitOfMeasure::unitOfMeasureIdBySymbol(
'ea'
));
unitConverter.parmRoundAbsoluteValue(NoYes::No);
unitConverter.parmApplyRounding(NoYes::No);
print unitConverter.convertValue(1010);
//Method two
print UnitOfMeasureConverter::convert(1010,
UnitOfMeasure::unitOfMeasureIdBySymbol(
'kg'
),
UnitOfMeasure::unitOfMeasureIdBySymbol(
'ea'
),
NoYes::No,
InventTable::itemProduct(#itemId),
NoYes::No);
pause;
}
===============================================================================================
Unit Conversion Check AX2009 Vs AX2012
AX 2009
if(!UnitConvert::canConvert(this.inventTableModuleInvent().UnitId, this.SAB_ProdPickingUOM, this.ItemId))
AX 2012
unitConvFound = UnitOfMeasureConverter::canBeConverted(UnitOfMeasure::findBySymbol(this.inventTableModuleInvent().UnitId).RecId, UnitOfMeasure::findBySymbol(this.SAB_SalesPickingUOM).RecId,
this.Product);
No comments:
Post a Comment