static void ASM_UpdateDefaultOrderSettings(Args _args)
{
InventTable inventTable;
InventItemInventSetup inventItemInventSetup;
InventItemPurchSetup inventItemPurchSetup;
InventItemSalesSetup inventItemSalesSetup;
InventDim inventDim;
DataArea dataArea;
InventDimid inventDimid;
InventSite lInventSite;
;
inventTable = InventTable::find("S403010", true);
While select dataArea where !dataArea.isVirtual && ( dataArea.id == "xsd")
{
changeCompany(dataArea.Id)
{
inventDimid = "";
inventTable = null;
lInventSite = null;
inventDim = null;
select firstonly lInventSite where lInventSite.dataAreaId == dataArea.id;
if (lInventSite.RecId)
{
while select * from inventTable
{
ttsBegin;
//select firstonly lInventSite
inventDim.initValue();
inventDim.InventSiteId = lInventSite.SiteId;//"AUS";
inventDim.inventLocationId = "standard";
inventDim = InventDim::findOrCreate(inventDim);
//Site specific setup
/*
inventItemInventSetup.initValue();
inventItemInventSetup.InventDimId = inventDim.inventDimId;
inventItemInventSetup.ItemId = inventTable.ItemId;
inventItemInventSetup.insert();
inventItemPurchSetup.initValue();
inventItemPurchSetup.InventDimId = inventDim.inventDimId;
inventItemPurchSetup.ItemId = inventTable.ItemId;
inventItemPurchSetup.insert();
inventItemSalesSetup.initValue();
inventItemSalesSetup.InventDimId = inventDim.inventDimId;
inventItemSalesSetup.ItemId = inventTable.ItemId;
inventItemSalesSetup.insert(); */
//Default order settings
inventItemInventSetup= inventItemInventSetup::findDefault(inventTable.itemId, true);
if(inventItemInventSetup.RecId)
{
inventItemInventSetup.InventDimIdDefault = inventDim.inventDimId;
inventItemInventSetup.update();
}
else
{
inventItemInventSetup.initValue();
inventItemInventSetup.InventDimId = inventDim.inventDimId;
inventItemInventSetup.ItemId = inventTable.ItemId;
inventItemInventSetup.insert();
/* inventItemInventSetup= inventItemInventSetup::findDefault(inventTable.itemId, true);
inventItemInventSetup.InventDimIdDefault = inventDim.inventDimId;
inventItemInventSetup.update(); */
}
inventItemPurchSetup = inventItemPurchSetup::findDefault(inventTable.itemId, true);
if (inventItemPurchSetup.RecId)
{
inventItemPurchSetup.InventDimIdDefault = inventDim.inventDimId;
inventItemPurchSetup.update();
}
else
{
inventItemPurchSetup.initValue();
inventItemPurchSetup.InventDimId = inventDim.inventDimId;
inventItemPurchSetup.ItemId = inventTable.ItemId;
inventItemPurchSetup.insert();
/* inventItemPurchSetup = inventItemPurchSetup::findDefault(inventTable.itemId, true);
inventItemPurchSetup.InventDimIdDefault = inventDim.inventDimId;
inventItemPurchSetup.update(); */
}
inventItemSalesSetup= inventItemSalesSetup::findDefault(inventTable.itemId, true);
if(inventItemSalesSetup.RecId)
{
inventItemSalesSetup.InventDimIdDefault = inventDim.inventDimId;
inventItemSalesSetup.update();
}
else
{
inventItemSalesSetup.initValue();
inventItemSalesSetup.InventDimId = inventDim.inventDimId;
inventItemSalesSetup.ItemId = inventTable.ItemId;
inventItemSalesSetup.insert();
/* inventItemSalesSetup= inventItemSalesSetup::findDefault(inventTable.itemId, true);
inventItemSalesSetup.InventDimIdDefault = inventDim.inventDimId;
inventItemSalesSetup.update(); */
}
ttsCommit;
}
}
}
}
}
{
InventTable inventTable;
InventItemInventSetup inventItemInventSetup;
InventItemPurchSetup inventItemPurchSetup;
InventItemSalesSetup inventItemSalesSetup;
InventDim inventDim;
DataArea dataArea;
InventDimid inventDimid;
InventSite lInventSite;
;
inventTable = InventTable::find("S403010", true);
While select dataArea where !dataArea.isVirtual && ( dataArea.id == "xsd")
{
changeCompany(dataArea.Id)
{
inventDimid = "";
inventTable = null;
lInventSite = null;
inventDim = null;
select firstonly lInventSite where lInventSite.dataAreaId == dataArea.id;
if (lInventSite.RecId)
{
while select * from inventTable
{
ttsBegin;
//select firstonly lInventSite
inventDim.initValue();
inventDim.InventSiteId = lInventSite.SiteId;//"AUS";
inventDim.inventLocationId = "standard";
inventDim = InventDim::findOrCreate(inventDim);
//Site specific setup
/*
inventItemInventSetup.initValue();
inventItemInventSetup.InventDimId = inventDim.inventDimId;
inventItemInventSetup.ItemId = inventTable.ItemId;
inventItemInventSetup.insert();
inventItemPurchSetup.initValue();
inventItemPurchSetup.InventDimId = inventDim.inventDimId;
inventItemPurchSetup.ItemId = inventTable.ItemId;
inventItemPurchSetup.insert();
inventItemSalesSetup.initValue();
inventItemSalesSetup.InventDimId = inventDim.inventDimId;
inventItemSalesSetup.ItemId = inventTable.ItemId;
inventItemSalesSetup.insert(); */
//Default order settings
inventItemInventSetup= inventItemInventSetup::findDefault(inventTable.itemId, true);
if(inventItemInventSetup.RecId)
{
inventItemInventSetup.InventDimIdDefault = inventDim.inventDimId;
inventItemInventSetup.update();
}
else
{
inventItemInventSetup.initValue();
inventItemInventSetup.InventDimId = inventDim.inventDimId;
inventItemInventSetup.ItemId = inventTable.ItemId;
inventItemInventSetup.insert();
/* inventItemInventSetup= inventItemInventSetup::findDefault(inventTable.itemId, true);
inventItemInventSetup.InventDimIdDefault = inventDim.inventDimId;
inventItemInventSetup.update(); */
}
inventItemPurchSetup = inventItemPurchSetup::findDefault(inventTable.itemId, true);
if (inventItemPurchSetup.RecId)
{
inventItemPurchSetup.InventDimIdDefault = inventDim.inventDimId;
inventItemPurchSetup.update();
}
else
{
inventItemPurchSetup.initValue();
inventItemPurchSetup.InventDimId = inventDim.inventDimId;
inventItemPurchSetup.ItemId = inventTable.ItemId;
inventItemPurchSetup.insert();
/* inventItemPurchSetup = inventItemPurchSetup::findDefault(inventTable.itemId, true);
inventItemPurchSetup.InventDimIdDefault = inventDim.inventDimId;
inventItemPurchSetup.update(); */
}
inventItemSalesSetup= inventItemSalesSetup::findDefault(inventTable.itemId, true);
if(inventItemSalesSetup.RecId)
{
inventItemSalesSetup.InventDimIdDefault = inventDim.inventDimId;
inventItemSalesSetup.update();
}
else
{
inventItemSalesSetup.initValue();
inventItemSalesSetup.InventDimId = inventDim.inventDimId;
inventItemSalesSetup.ItemId = inventTable.ItemId;
inventItemSalesSetup.insert();
/* inventItemSalesSetup= inventItemSalesSetup::findDefault(inventTable.itemId, true);
inventItemSalesSetup.InventDimIdDefault = inventDim.inventDimId;
inventItemSalesSetup.update(); */
}
ttsCommit;
}
}
}
}
}
No comments:
Post a Comment