Situation:
- Allow back-flushing of 92Kg of ingredient, even though only 90Kg are available; No negative stock allowed.
- I did this by modifying the production order before reporting as finished.
- For this I needed a way to find out how much the system will back-flush (e.g. 92Kg). The difficulty is that we use phantom BOMs and Routes, which makes the calculation rather complicated.
- NOTE: Activating the production parameter "Physical reduction" (Journals tab), also reduces the quantity automatically to depleat only available stock. But we wanted more controll over this process.
Solution:
- Access the functionality used by Dynamics Ax for this calculation.
- Note: The production must be started for the phantoms to be exploded.
//bw start
//Changed on 22 May 2007 by TW
/* Description:
Get the expected BOM line qty to be used
Production must be started to take Phantom BOM/Routes into account
*/
static public Qty prodItemQty(ProdBOM _prodBom, Qty _seriesSize=0)
{
ProdTable prodTable = ProdTable::find(_prodBom.BOMId);
BOMCalcData bomCalcData;
BOMCalcConsumption itemCalcLine;
UnitQty bomProposal;
InventQty inventProposal;
Qty seriesSize = _seriesSize;
;
if (!seriesSize)
{
if(prodTable.ProdStatus==ProdStatus::StartedUp)
seriesSize = prodTable.QtyStUp-(prodTable.reportedFinishedGood()+prodTable.reportedFinishedError());
else
seriesSize = prodTable.QtySched;
}
bomCalcData = BOMCalcData::newProdTable(seriesSize,_prodTable);
itemCalcLine = BOMCalcConsumption::construct(_prodBom.Formula,bomCalcData);
bomProposal = itemCalcLine.calcConsumption(_prodBom,
ProdRoute::accError(_prodBOM.ProdId,_prodBOM.OprNum),
NoYes::Yes);
inventProposal = UnitConvert::qty(
bomProposal,
_prodBOM.UnitId,
InventTableModule::find(_prodBOM.ItemId,ModuleInventPurchSales::Invent).UnitId,
_prodBOM.ItemId);
return inventProposal;
}
//bw end

Leave a Reply