//The function below explodes BOM to the lowest level.
//You should create PlanBOM table before executing this function or change the code according to your target.
void explodeBOM()
{
ETGProdPlanBOMTable PlanBOM;
void qtyexplode(ETGProdPlanId _planid, ItemId _ItemId,Qty _qtySerie,int _level)
{
BOM BOMd;
InventTable itabled;
BOMVersion BOMVersiond;
;
select firstonly BOMVersiond
where BOMVersiond.ItemId == _itemid
&& BOMVersiond.Active
&& BOMVersiond.FromDate <= systemdateget()
&& (!BOMVersiond.ToDate || BOMVersiond.ToDate >= systemdateget());
if (BOMVersiond.RecId)
{
While select BOMd
where BOMd.BOMId == BOMVersiond.BOMId
join itabled
where BOMd.ItemId == itabled.ItemId
{
if (itabled.ItemType == ItemType::Item)
{
PlanBOM.clear();
PlanBOM.ItemId = BOMd.ItemId;
PlanBOM.RefItemId = BOMVersiond.ItemId;
PlanBOM.Qty = BOMd.BOMQty / BOMd.BOMQtySerie * _qtyserie;
PlanBOM.PlanId = _planid;
PlanBOM.Level = _level;
PlanBOM.insert();
}
else if (itabled.ItemType == ItemType::BOM)
{
qtyexplode(_planid, BOMd.ItemId, BOMd.BOMQty/BOMd.BOMQtySerie * _qtySerie, _level+1);
}
}
}
}
;
delete_from PlanBOM
where PlanBOM.PlanId == this.ProdPlanrec().PlanId;
qtyexplode(this.ProdPlanrec().PlanId, this.ProdPlanrec().ItemId,this.ProdPlanrec().Qty,1);
}
30 Temmuz 2008 Çarşamba
Kaydol:
Kayıt Yorumları (Atom)
Hiç yorum yok:
Yorum Gönder