InventDim inventDim,invDim;
InventTable inventTable;
inventDimId inventDimId;
InventItemPurchSetup invPurch;
InventItemSalesSetup invSal;
InventItemInventSetup invInvent;
while select inventTable
{
invDim.clear();
Select forUpdate invDim where invDim.InventSiteId == "AD" && invDim.InventLocationId == '' && InvDim.InventBatchId == '';
if (!invDim)
{
invDim.InventBatchId = '';
invDim.InventLocationId = '';
invDim.InventSiteId = "AD";
invDim = InventDim::findOrCreate(invDim);
}
inventDimId = invDim.InventDimId;
// Delete existing dimensions
delete_from invPurch where invPurch.ItemId == inventTable.ItemId &&
invPurch.InventDimId != "AllBlank";
// Purchase Location Id
invDim.clear();
Select forUpdate invDim where invDim.InventSiteId == '' && invDim.InventLocationId == "AD-DRY" && InvDim.InventBatchId == '';
if (!invDim)
{
invDim.InventBatchId = '';
invDim.InventLocationId = "AD-DRY";
invDim.InventSiteId = '';
invDim.initFromInventLocation(invDim.inventLocation());
invDim = InventDim::findOrCreate(invDim);
}
// Dimension for Location
invPurch.clear();
invPurch.initFromDefault();
invPurch.ItemId = inventTable.ItemId;
invPurch.InventDimId = inventDimId;
invPurch.InventDimIdDefault = invDim.InventDimId;
invPurch.insert();
delete_from invSal where invSal.ItemId == inventTable.ItemId &&
invSal.InventDimId != "AllBlank";
invSal.clear();
invSal.initFromDefault();
invSal.ItemId = inventTable.ItemId;
invSal.InventDimId = inventDimId;
invSal.InventDimIdDefault = invDim.InventDimId;
invSal.insert();
delete_from invInvent where invInvent.ItemId == inventTable.ItemId &&
invInvent.InventDimId != "AllBlank";
invInvent.clear();
invInvent.initFromDefault();
invInvent.ItemId = inventTable.ItemId;
invInvent.InventDimId = inventDimId;
invInvent.InventDimIdDefault = invDim.InventDimId;
invInvent.insert();
}
No comments:
Post a Comment