static void MK_SiteSpecificSetupCreate(Args _args)
{
InventTable inventTable;
InventItemInventSetup inventItemInventSetup;
InventItemPurchSetup inventItemPurchSetup;
InventItemSalesSetup inventItemSalesSetup;
InventDim _inventdimPurch;
InventDim inventDim;
DataArea dataArea;
InventDimid inventDimid;
InventDim lInventDim;
Inventsite inventSite;
;
While select dataArea where !dataArea.isVirtual
{
//ttsbegin;
cl ++;
changeCompany(dataArea.Id)
{
inventDimid = "";
inventTable = null;
while select inventTable where inventTable.dataAreaId == dataArea.Id
{
InventItemPurchSetup = null;
_inventdimPurch = null;
inventItemPurchSetup = null;
inventItemSalesSetup = null;
inventItemInventSetup = null;
inventSite = null;
select firstonly inventSite where inventSite.dataAreaId == dataArea.Id;
if (inventsite.RecId)
{
inventDim.InventSiteId = inventsite.SiteId;
}
else
{
inventDim.InventSiteId = "AUS";
}
inventDimid = InventDim::findOrCreate(inventDim).inventDimId;
//inventTable = InventTable::find("S403040", true);
if(inventDimid && inventTable.ItemId)//if _inventdimid -- BEGIN
{
if(InventItemPurchSetup::exist(inventTable.ItemId,inventDimid) == false)
{
ttsbegin;
inventItemPurchSetup.InventDimId = inventDimid;
inventItemPurchSetup.ItemId = inventTable.ItemId;
_inventdimPurch.InventLocationId = "standard";
inventItemPurchSetup.InventDimIdDefault = InventDim::findOrCreate(_inventdimPurch).inventDimId;
inventItemPurchSetup.insert();
inventItemPurchSetup.validateWrite();
inventItemInventSetup.ItemId = inventTable.ItemId;
inventItemInventSetup.InventDimId = inventItemPurchSetup.InventDimId;
inventItemInventSetup.InventDimIdDefault = InventDim::findOrCreate(_inventdimPurch).inventDimId;
inventItemInventSetup.insert();
inventItemInventSetup.validateWrite();
inventItemSalesSetup.ItemId = inventTable.ItemId;
inventItemSalesSetup.InventDimId = inventItemPurchSetup.InventDimId;
inventItemSalesSetup.InventDimIdDefault = InventDim::findOrCreate(_inventdimPurch).inventDimId;
inventItemSalesSetup.insert();
inventItemSalesSetup.validateWrite();
ttscommit;
}
}
}//while
}// change company
}//while
}
{
InventTable inventTable;
InventItemInventSetup inventItemInventSetup;
InventItemPurchSetup inventItemPurchSetup;
InventItemSalesSetup inventItemSalesSetup;
InventDim _inventdimPurch;
InventDim inventDim;
DataArea dataArea;
InventDimid inventDimid;
InventDim lInventDim;
Inventsite inventSite;
;
While select dataArea where !dataArea.isVirtual
{
//ttsbegin;
cl ++;
changeCompany(dataArea.Id)
{
inventDimid = "";
inventTable = null;
while select inventTable where inventTable.dataAreaId == dataArea.Id
{
InventItemPurchSetup = null;
_inventdimPurch = null;
inventItemPurchSetup = null;
inventItemSalesSetup = null;
inventItemInventSetup = null;
inventSite = null;
select firstonly inventSite where inventSite.dataAreaId == dataArea.Id;
if (inventsite.RecId)
{
inventDim.InventSiteId = inventsite.SiteId;
}
else
{
inventDim.InventSiteId = "AUS";
}
inventDimid = InventDim::findOrCreate(inventDim).inventDimId;
//inventTable = InventTable::find("S403040", true);
if(inventDimid && inventTable.ItemId)//if _inventdimid -- BEGIN
{
if(InventItemPurchSetup::exist(inventTable.ItemId,inventDimid) == false)
{
ttsbegin;
inventItemPurchSetup.InventDimId = inventDimid;
inventItemPurchSetup.ItemId = inventTable.ItemId;
_inventdimPurch.InventLocationId = "standard";
inventItemPurchSetup.InventDimIdDefault = InventDim::findOrCreate(_inventdimPurch).inventDimId;
inventItemPurchSetup.insert();
inventItemPurchSetup.validateWrite();
inventItemInventSetup.ItemId = inventTable.ItemId;
inventItemInventSetup.InventDimId = inventItemPurchSetup.InventDimId;
inventItemInventSetup.InventDimIdDefault = InventDim::findOrCreate(_inventdimPurch).inventDimId;
inventItemInventSetup.insert();
inventItemInventSetup.validateWrite();
inventItemSalesSetup.ItemId = inventTable.ItemId;
inventItemSalesSetup.InventDimId = inventItemPurchSetup.InventDimId;
inventItemSalesSetup.InventDimIdDefault = InventDim::findOrCreate(_inventdimPurch).inventDimId;
inventItemSalesSetup.insert();
inventItemSalesSetup.validateWrite();
ttscommit;
}
}
}//while
}// change company
}//while
}
No comments:
Post a Comment