Introduction:
after a lot of googling on "Alternative items in AX 2012 R3 Production Orders", i found only one answer "use plan group which located in formula line Form", I tried this way more than 4-8 times with no result. I already asked some consultant peoples about what i need to create groups of raw material items and link some alternative items with them group and when one item used in production formula doesn't have enough quantity use another item on the same group which have enough quantity for the production order, they also told me the same way which i found it on google and when i told them that i tried it they told me that you need cumulative update but i tried to update and also no result but i found that the Plan Group only work on Planned Orders or MRP "Master Plan"
So i decided to found another way to do my job Let's Start......
- Create table for Items Group
- Create table for Alternative Items linked with them group
- Create form to Insert/Update/Delete Items or Groups
prodBOM.selectForUpdate(true);
//Start of customization
availQty = ItemInfo::ItemQtyByInventDimId(prodBom.inventDim().inventDimId,prodBom.ItemId);
itemConsumeQty = (prodTable.QtyStUp * prodBOM.BOMQty)/prodBOM.BOMQtySerie;
if(itemConsumeQty > availQty)
{
altInventDim = prodBom.InventDim();
c = AlternativeItems::findItemId(prodBom.ItemId,itemConsumeQty,altInventDim);
if (c && conpeek(c,1) != "")
{
altItemId = conpeek(c,1);
prodBom.ItemId = altItemId;
if (altInventDim)
prodBom.InventDimId = altInventDim.inventDimId;
else
prodBom.InventDimId = InventDim::inventDimIdBlank();
}
}
//End of customization
findItemId is a method on table that we create to find suitable item have enough qty for production order
ItemInfo is class contain function that return the physical available qty on given InventDimId