static void UpdateImportItem(Args _args)
{
SysExcelApplication xlsApplication;
SysExcelWorkBooks xlsWorkBookCollection;
SysExcelWorkBook xlsWorkBook;
SysExcelWorksheets xlsWorkSheetCollection;
SysExcelWorksheet xlsWorkSheet;
SysExcelRange xlsRange;
SysExcelCells Cells;
SysExcelCell RCell;
CommaIO inFile;
int nRow,i;
DialogField dialogPath;
Dialog dialog;
Filename filename;
EcoResProductMaster ecoResProductMaster;
EcoResProductIdentifier ecoResProductIdentifier;
EcoResProductDimensionGroupProduct ecoResProductDimensionGroupProduct;
EcoResProductMasterModelingPolicy ecoResProductMasterModelingPolicy;
EcoResStorageDimensionGroupProduct ecoResStorageDimensionGroupProduct;
EcoResTrackingDimensionGroupProduct ecoResTrackingDimensionGroupProduct;
EcoResConfiguration ecoResConfiguration;
EcoResProductMasterConfiguration ecoResProductMasterConfiguration;
EcoResDistinctProductVariant ecoResDistinctProductVariant;
EcoResProductVariantConfiguration ecoResProductVariantConfiguration;
InventTable inventTable;
InventTableModule inventTableModule;
InventItemSetupSupplyType inventItemSetupSupplyType;
EcoResStorageDimensionGroupItem ecoResStorageDimensionGroupItem;
EcoResTrackingDimensionGroupItem ecoResTrackingDimensionGroupItem;
InventModelGroupItem inventModelGroupItem;
InventItemGroupItem inventItemGroupItem;
InventDim inventDim;
InventDimCombination inventDimCombination;
//PdsCWProduct pdsCWProduct;
EcoResProductDisplayProductNumber ecoResProductDisplayProductNumber;
EcoResProductSearchName ecoResProductSearchName;
EcoResProductType ecoResProductType;
EcoResDistinctProduct ecoResDistinctProduct;
//Traslation
EcoResProductTranslation ecoResProductTranslation;
LanguageId LanguageId;
EcoResProductName ecoResProductName;
EcoResDescription ecoResDescription;
//EcoResProductDimensionGroup
EcoResProductDimensionGroup ecoResProductDimensionGroup;
EcoResProductDimensionGroupName ecoResProductDimensionGroupName;
Description description;
//EcoResStorageDimensionGroup
EcoResStorageDimensionGroup ecoResStorageDimensionGroup;
EcoResStorageDimensionGroupName ecoResStorageDimensionGroupName;
//Description description;
//EcoResTrackingDimensionGroup
EcoResTrackingDimensionGroup ecoResTrackingDimensionGroup;
EcoResTrackingDimensionGroupName ecoResTrackingDimensionGroupName;
//EcoResProductMaster
//RetailColorGroupId retailColorGroupId;
//RetailSizeGroupId retailSizeGroupId;
//RetailStyleGroupId retailStyleGroupId;
EcoResVariantConfigurationTechnologyType ecoResVariantConfigurationTechnologyType;
;
dialog = new Dialog("Import");
dialogPath = dialog.addField(extendedTypeStr(Filenameopen), "File Name");
dialog.run();
if (dialog.run())
{
filename = (dialogPath.value());
}
inFile = new CommaIO (filename, 'R');
if (!inFile || infile.status() != IO_Status::Ok )
{
throw error (strfmt("@SYS19312",filename));
}
try
{
xlsApplication = SysExcelApplication::construct();
xlsWorkBookCollection = xlsApplication.workbooks();
xlsWorkBookCollection.open(filename);
xlsWorkSheetCollection = xlsApplication.worksheets();
xlsWorkSheet = xlsWorkSheetCollection.itemFromNum(1);
Cells = xlsWorkSheet.Cells();
nRow = 2;
RCell = Cells.Item(nRow, 1);
while (RCell.value().bStr() != "")
{
ecoResProductDisplayProductNumber = RCell.value().bStr();
RCell = Cells.item(nRow,2);
//pdsCWProduct = any2enum( RCell.value().bStr());
RCell = Cells.item(nRow,3);
ecoResProductType =str2enum(ecoresproducttype, RCell.value().bStr());
RCell = Cells.item(nRow,4);
ecoResProductSearchName = RCell.value().bStr();
RCell = Cells.item(nRow,5);
ecoResProductName = RCell.value().bStr();
RCell = Cells.item(nRow,6);
ecoResDescription = RCell.value().bStr();
RCell = Cells.item(nRow,7);
LanguageId = RCell.value().bStr();
RCell = Cells.item(nRow,8);
ecoResProductDimensionGroupName = RCell.value().bStr();
RCell = Cells.item(nRow,9);
description = RCell.value().bStr();
RCell = Cells.item(nRow,10);
ecoResStorageDimensionGroupName = RCell.value().bStr();
RCell = Cells.item(nRow,11);
description = RCell.value().bStr();
RCell = Cells.item(nRow,12);
ecoResTrackingDimensionGroupName = RCell.value().bStr();
RCell = Cells.item(nRow,13);
description = RCell.value().bStr();
RCell = Cells.item(nRow,14);
//retailColorGroupId = RCell.value().bStr();
RCell = Cells.item(nRow,15);
//retailSizeGroupId = RCell.value().bStr();
RCell = Cells.item(nRow,16);
//retailStyleGroupId = RCell.value().bStr();
RCell = Cells.item(nRow,17);
ecoResVariantConfigurationTechnologyType = str2enum(ecoResVariantConfigurationTechnologyType, RCell.value().bStr());
nRow++;
RCell = Cells.Item(nRow, 1);
}
xlsApplication.quit ();
xlsApplication.finalize ();
// info("Import completed");
}
catch( Exception::Error)
{
//Close Excel.
xlsApplication.quit ();
xlsApplication.finalize ();
ttsabort;
info("Unable to process the excel import ");
}
try
{
//ProductMaster
// ecoResProductMaster.clear();
// ecoResProductMaster.initValue();
select forUpdate RecId from ecoResProductMaster where ecoResProductMaster.DisplayProductNumber== ecoResProductDisplayProductNumber;
{
ecoResProductMaster.ProductType = ecoResProductType;
ecoResProductMaster.DisplayProductNumber = ecoResProduct::findByProductNumber(ecoResProductDisplayProductNumber).DisplayProductNumber;
ecoResProductMaster.SearchName = ecoResProductSearchName;
ecoResProductMaster.VariantConfigurationTechnology = ecoResVariantConfigurationTechnologyType;
//ecoResProductMaster.RetailColorGroupId = retailColorGroupId;
//ecoResProductMaster.RetailSizeGroupId = retailSizeGroupId;
// ecoResProductMaster.RetailStyleGroupId = retailStyleGroupId;
// if (ecoResProductMaster.validateWrite())
// {
ecoResProductMaster.update();
// ecoResProductIdentifier.clear();
// ecoResProductIdentifier.initValue();
select forUpdate RecId from ecoResProductIdentifier where ecoResProductIdentifier.Product == ecoResProductMaster.RecId;
{
ecoResProductIdentifier.ProductNumber = ecoResProductDisplayProductNumber;
// ecoResProductIdentifier.update();
}
//Product dimension group
// ecoResProductDimensionGroupProduct.clear();
// ecoResProductDimensionGroupProduct.initValue();
// ecoResProductDimensionGroupProduct.initFromProduct(ecoResProductMaster);
ecoResProductDimensionGroupProduct.ProductDimensionGroup = EcoResProductDimensionGroup::findByDimensionGroupName(ecoResProductDimensionGroupName).RecId;
// if (ecoResProductDimensionGroupProduct.validateWrite())
//{
// ecoResProductDimensionGroupProduct.update();
//}
//Storage dimension group
// ecoResStorageDimensionGroupProduct.clear();
// ecoResStorageDimensionGroupProduct.initValue();
select forUpdate RecId from ecoResStorageDimensionGroupProduct where ecoResStorageDimensionGroupProduct.Product == ecoResProductMaster.RecId;
ecoResStorageDimensionGroupProduct.StorageDimensionGroup = EcoResStorageDimensionGroup::findByDimensionGroupName(ecoResStorageDimensionGroupName).RecId;
// if (ecoResStorageDimensionGroupProduct.validateWrite())
// {
// ecoResStorageDimensionGroupProduct.update();
// }
//Tracking dimension group
// ecoResTrackingDimensionGroupProduct.clear();
// ecoResTrackingDimensionGroupProduct.initValue();
select forUpdate RecId from ecoResTrackingDimensionGroupProduct where ecoResTrackingDimensionGroupProduct.Product == ecoResProductMaster.RecId;
ecoResTrackingDimensionGroupProduct.TrackingDimensionGroup = EcoResTrackingDimensionGroup::findByDimensionGroupName(ecoResTrackingDimensionGroupName).RecId;
//if (ecoResTrackingDimensionGroupProduct.validateWrite())
// {
// ecoResTrackingDimensionGroupProduct.update();
// }
//Product modeling policy
// ecoResProductMasterModelingPolicy.clear();
// ecoResProductMasterModelingPolicy.initValue();
// ecoResProductMasterModelingPolicy.ProductMaster == ecoResProductMaster.RecId;
// if (ecoResProductMasterModelingPolicy.validateWrite())
// {
//ecoResProductMasterModelingPolicy.update();
// }
//Product translation
EcoResProductTranslation::createOrUpdateTranslation(ecoResProductMaster.RecId, ecoResProductName, ecoResDescription);
//Configuration
ecoResConfiguration = EcoResConfiguration::findByName(description);
if (!ecoResConfiguration)
{
// ecoResConfiguration.clear();
//ecoResConfiguration.initValue();
ecoResConfiguration.Name = description;
// ecoResConfiguration.update();
}
//Configuration assigned to product master
//ecoResProductMasterConfiguration.clear();
// ecoResProductMasterConfiguration.initValue();
select forupdate RecId from ecoResProductMasterConfiguration where ecoResProductMasterConfiguration.Configuration == ecoResConfiguration.RecId;
// ecoResProductMasterConfiguration.Configuration = ecoResConfiguration.RecId;
{
ecoResProductMasterConfiguration.Description = description;
ecoResProductMasterConfiguration.ConfigProductDimensionAttribute = EcoResProductDimensionAttribute::inventDimFieldId2DimensionAttributeRecId(fieldNum(InventDim, ConfigId));
ecoResProductMasterConfiguration.ConfigProductMaster = ecoResProductMaster.RecId;
// ecoResProductMasterConfiguration.update();
}
//Product variant
// ecoResDistinctProductVariant.clear();
// ecoResDistinctProductVariant.initValue();
ecoResDistinctProductVariant.DisplayProductNumber = EcoResProductNumberBuilderVariant::buildFromProductNumberAndDimensions(
ecoResProductMaster.productNumber(),
EcoResProductVariantDimValue::getDimensionValuesContainer(description, "", ""));
ecoResDistinctProductVariant.SearchName = ecoResProductMaster.SearchName + ecoResProductSearchName/*ConfigId*/;
ecoResDistinctProductVariant.ProductType = ecoResProductMaster.ProductType;
ecoResDistinctProductVariant.ProductMaster = ecoResDistinctProductVariant::find(ecoResProductMaster.RecId).ProductMaster;
// ecoResDistinctProductVariant.update();
//Product variant configuration
// ecoResProductVariantConfiguration.clear();
// ecoResProductVariantConfiguration.initValue();
ecoResProductVariantConfiguration.initFromDistinctProductVariant(ecoResDistinctProductVariant);
ecoResProductVariantConfiguration.ProductDimensionAttribute = EcoResProductDimensionAttribute::inventDimFieldId2DimensionAttributeRecId(fieldNum(InventDim, ConfigId));
ecoResProductVariantConfiguration.Configuration = ecoResConfiguration.RecId;
// ecoResProductVariantConfiguration.update();
//Product variant translation
EcoResProductTranslation::createOrUpdateTranslation(ecoResDistinctProductVariant.RecId, ecoResProductName, ecoResDescription);
}
//Released product
// inventTable.clear();
// inventTable.initValue();
inventTable.initFromEcoResProduct(ecoResProductMaster);
select forupdate RecId from inventTable where inventTable.ItemId == ecoResProductDisplayProductNumber;
{
inventTable.NameAlias = ecoResProductSearchName;
// if (inventTable.validateWrite())
// {
// inventTable.update();
}
//Inventory model group
// inventModelGroupItem.clear();
// inventModelGroupItem.initValue();
select forUpdate RecId from inventModelGroupItem where inventModelGroupItem.ItemId == inventTable.ItemId;
{
inventModelGroupItem.ItemDataAreaId = inventTable.dataAreaId;
//inventModelGroupItem.ItemId = inventTable.ItemId;
inventModelGroupItem.ModelGroupId = "FIFO";
inventModelGroupItem.ModelGroupDataAreaId = curext();
// inventModelGroupItem.update();
}
//Item group
// inventItemGroupItem.clear();
//inventItemGroupItem.initValue();
select forUpdate RecId from inventItemGroupItem where inventItemGroupItem.ItemId == inventTable.ItemId;
{
inventItemGroupItem.ItemDataAreaId = inventTable.dataAreaId;
//inventItemGroupItem.ItemId = inventTable.ItemId;
inventItemGroupItem.ItemGroupId = "Parts";
inventItemGroupItem.ItemGroupDataAreaId = curext();
// inventItemGroupItem.update();
}
//Extended product details - Inventory
// inventTableModule.clear();
// inventTableModule.initValue();
select forUpdate RecId from inventTableModule where inventTableModule.ItemId == inventTable.ItemId;
{
inventTableModule.ModuleType = ModuleInventPurchSales::Invent;
// inventTableModule.update();
}
//Extended product details - Purchase
// inventTableModule.clear();
// inventTableModule.initValue();
select forUpdate RecId from inventTableModule where inventTableModule.ItemId == inventTable.ItemId;
{
inventTableModule.ModuleType = ModuleInventPurchSales::Purch;
// inventTableModule.update();
}
//Extended product details - Sales
// inventTableModule.clear();
// inventTableModule.initValue();
select forUpdate RecId from inventTableModule where inventTableModule.ItemId == inventTable.ItemId;
{
inventTableModule.ModuleType = ModuleInventPurchSales::Sales;
// inventTableModule.update();
}
//Warehouse items
InventItemLocation::findDefault(inventTable.ItemId);
//Supply type setup
//inventItemSetupSupplyType.clear();
//inventItemSetupSupplyType.initValue();
select forUpdate RecId from inventItemSetupSupplyType where inventItemSetupSupplyType.ItemId == inventTable.ItemId;
{
inventItemSetupSupplyType.ItemDataAreaId = inventTable.DataAreaId;
// inventItemSetupSupplyType.update();
}
//Product storage dimension group
ecoResStorageDimensionGroupProduct = EcoResStorageDimensionGroupProduct::findByProduct(ecoResProductMaster.RecId);
if (ecoResStorageDimensionGroupProduct.RecId)
{
//ecoResStorageDimensionGroupItem.clear();
// ecoResStorageDimensionGroupItem.initValue();
select forUpdate RecId from ecoResStorageDimensionGroupItem where ecoResStorageDimensionGroupItem.ItemId == inventTable.ItemId;
{
ecoResStorageDimensionGroupItem.ItemDataAreaId = inventTable.DataAreaId;
// ecoResStorageDimensionGroupItem.ItemId = inventTable.ItemId;
ecoResStorageDimensionGroupItem.StorageDimensionGroup = ecoResStorageDimensionGroupProduct.StorageDimensionGroup;
// ecoResStorageDimensionGroupItem.update();
}
}
//Product tracking dimension group
ecoResTrackingDimensionGroupProduct = EcoResTrackingDimensionGroupProduct::findByProduct(ecoResProductMaster.RecId);
if (ecoResTrackingDimensionGroupProduct.RecId)
{
//ecoResTrackingDimensionGroupItem.clear();
// ecoResTrackingDimensionGroupItem.initValue();
select forUpdate RecId from ecoResTrackingDimensionGroupItem where ecoResTrackingDimensionGroupItem.ItemId == inventTable.ItemId;
ecoResTrackingDimensionGroupItem.ItemDataAreaId = inventTable.DataAreaId;
// ecoResTrackingDimensionGroupItem.ItemId = inventTable.ItemId;
ecoResTrackingDimensionGroupItem.TrackingDimensionGroup = ecoResTrackingDimensionGroupProduct.TrackingDimensionGroup;
// ecoResTrackingDimensionGroupItem.update();
}
// }
// inventDim.clear();
inventDim.ConfigId = description;/*ConfigId*/
inventDim = InventDim::findOrCreate(inventDim);
//Released product variant
// inventDimCombination.clear();
// inventDimCombination.initValue();
inventDimCombination.DistinctProductVariant = inventDimCombination::findByDistinctProductVariant(ecoResDistinctProductVariant.RecId).DistinctProductVariant;
select forupdate RecId from inventDimCombination where inventDimCombination.ItemId == inventTable.ItemId;
{
inventDimCombination.InventDimId = inventDim.InventDimId;
//inventDimCombination.update();
}
}
//}
catch
{
error("Error!");
return;
}
info("Import completed !");
}
{
SysExcelApplication xlsApplication;
SysExcelWorkBooks xlsWorkBookCollection;
SysExcelWorkBook xlsWorkBook;
SysExcelWorksheets xlsWorkSheetCollection;
SysExcelWorksheet xlsWorkSheet;
SysExcelRange xlsRange;
SysExcelCells Cells;
SysExcelCell RCell;
CommaIO inFile;
int nRow,i;
DialogField dialogPath;
Dialog dialog;
Filename filename;
EcoResProductMaster ecoResProductMaster;
EcoResProductIdentifier ecoResProductIdentifier;
EcoResProductDimensionGroupProduct ecoResProductDimensionGroupProduct;
EcoResProductMasterModelingPolicy ecoResProductMasterModelingPolicy;
EcoResStorageDimensionGroupProduct ecoResStorageDimensionGroupProduct;
EcoResTrackingDimensionGroupProduct ecoResTrackingDimensionGroupProduct;
EcoResConfiguration ecoResConfiguration;
EcoResProductMasterConfiguration ecoResProductMasterConfiguration;
EcoResDistinctProductVariant ecoResDistinctProductVariant;
EcoResProductVariantConfiguration ecoResProductVariantConfiguration;
InventTable inventTable;
InventTableModule inventTableModule;
InventItemSetupSupplyType inventItemSetupSupplyType;
EcoResStorageDimensionGroupItem ecoResStorageDimensionGroupItem;
EcoResTrackingDimensionGroupItem ecoResTrackingDimensionGroupItem;
InventModelGroupItem inventModelGroupItem;
InventItemGroupItem inventItemGroupItem;
InventDim inventDim;
InventDimCombination inventDimCombination;
//PdsCWProduct pdsCWProduct;
EcoResProductDisplayProductNumber ecoResProductDisplayProductNumber;
EcoResProductSearchName ecoResProductSearchName;
EcoResProductType ecoResProductType;
EcoResDistinctProduct ecoResDistinctProduct;
//Traslation
EcoResProductTranslation ecoResProductTranslation;
LanguageId LanguageId;
EcoResProductName ecoResProductName;
EcoResDescription ecoResDescription;
//EcoResProductDimensionGroup
EcoResProductDimensionGroup ecoResProductDimensionGroup;
EcoResProductDimensionGroupName ecoResProductDimensionGroupName;
Description description;
//EcoResStorageDimensionGroup
EcoResStorageDimensionGroup ecoResStorageDimensionGroup;
EcoResStorageDimensionGroupName ecoResStorageDimensionGroupName;
//Description description;
//EcoResTrackingDimensionGroup
EcoResTrackingDimensionGroup ecoResTrackingDimensionGroup;
EcoResTrackingDimensionGroupName ecoResTrackingDimensionGroupName;
//EcoResProductMaster
//RetailColorGroupId retailColorGroupId;
//RetailSizeGroupId retailSizeGroupId;
//RetailStyleGroupId retailStyleGroupId;
EcoResVariantConfigurationTechnologyType ecoResVariantConfigurationTechnologyType;
;
dialog = new Dialog("Import");
dialogPath = dialog.addField(extendedTypeStr(Filenameopen), "File Name");
dialog.run();
if (dialog.run())
{
filename = (dialogPath.value());
}
inFile = new CommaIO (filename, 'R');
if (!inFile || infile.status() != IO_Status::Ok )
{
throw error (strfmt("@SYS19312",filename));
}
try
{
xlsApplication = SysExcelApplication::construct();
xlsWorkBookCollection = xlsApplication.workbooks();
xlsWorkBookCollection.open(filename);
xlsWorkSheetCollection = xlsApplication.worksheets();
xlsWorkSheet = xlsWorkSheetCollection.itemFromNum(1);
Cells = xlsWorkSheet.Cells();
nRow = 2;
RCell = Cells.Item(nRow, 1);
while (RCell.value().bStr() != "")
{
ecoResProductDisplayProductNumber = RCell.value().bStr();
RCell = Cells.item(nRow,2);
//pdsCWProduct = any2enum( RCell.value().bStr());
RCell = Cells.item(nRow,3);
ecoResProductType =str2enum(ecoresproducttype, RCell.value().bStr());
RCell = Cells.item(nRow,4);
ecoResProductSearchName = RCell.value().bStr();
RCell = Cells.item(nRow,5);
ecoResProductName = RCell.value().bStr();
RCell = Cells.item(nRow,6);
ecoResDescription = RCell.value().bStr();
RCell = Cells.item(nRow,7);
LanguageId = RCell.value().bStr();
RCell = Cells.item(nRow,8);
ecoResProductDimensionGroupName = RCell.value().bStr();
RCell = Cells.item(nRow,9);
description = RCell.value().bStr();
RCell = Cells.item(nRow,10);
ecoResStorageDimensionGroupName = RCell.value().bStr();
RCell = Cells.item(nRow,11);
description = RCell.value().bStr();
RCell = Cells.item(nRow,12);
ecoResTrackingDimensionGroupName = RCell.value().bStr();
RCell = Cells.item(nRow,13);
description = RCell.value().bStr();
RCell = Cells.item(nRow,14);
//retailColorGroupId = RCell.value().bStr();
RCell = Cells.item(nRow,15);
//retailSizeGroupId = RCell.value().bStr();
RCell = Cells.item(nRow,16);
//retailStyleGroupId = RCell.value().bStr();
RCell = Cells.item(nRow,17);
ecoResVariantConfigurationTechnologyType = str2enum(ecoResVariantConfigurationTechnologyType, RCell.value().bStr());
nRow++;
RCell = Cells.Item(nRow, 1);
}
xlsApplication.quit ();
xlsApplication.finalize ();
// info("Import completed");
}
catch( Exception::Error)
{
//Close Excel.
xlsApplication.quit ();
xlsApplication.finalize ();
ttsabort;
info("Unable to process the excel import ");
}
try
{
//ProductMaster
// ecoResProductMaster.clear();
// ecoResProductMaster.initValue();
select forUpdate RecId from ecoResProductMaster where ecoResProductMaster.DisplayProductNumber== ecoResProductDisplayProductNumber;
{
ecoResProductMaster.ProductType = ecoResProductType;
ecoResProductMaster.DisplayProductNumber = ecoResProduct::findByProductNumber(ecoResProductDisplayProductNumber).DisplayProductNumber;
ecoResProductMaster.SearchName = ecoResProductSearchName;
ecoResProductMaster.VariantConfigurationTechnology = ecoResVariantConfigurationTechnologyType;
//ecoResProductMaster.RetailColorGroupId = retailColorGroupId;
//ecoResProductMaster.RetailSizeGroupId = retailSizeGroupId;
// ecoResProductMaster.RetailStyleGroupId = retailStyleGroupId;
// if (ecoResProductMaster.validateWrite())
// {
ecoResProductMaster.update();
// ecoResProductIdentifier.clear();
// ecoResProductIdentifier.initValue();
select forUpdate RecId from ecoResProductIdentifier where ecoResProductIdentifier.Product == ecoResProductMaster.RecId;
{
ecoResProductIdentifier.ProductNumber = ecoResProductDisplayProductNumber;
// ecoResProductIdentifier.update();
}
//Product dimension group
// ecoResProductDimensionGroupProduct.clear();
// ecoResProductDimensionGroupProduct.initValue();
// ecoResProductDimensionGroupProduct.initFromProduct(ecoResProductMaster);
ecoResProductDimensionGroupProduct.ProductDimensionGroup = EcoResProductDimensionGroup::findByDimensionGroupName(ecoResProductDimensionGroupName).RecId;
// if (ecoResProductDimensionGroupProduct.validateWrite())
//{
// ecoResProductDimensionGroupProduct.update();
//}
//Storage dimension group
// ecoResStorageDimensionGroupProduct.clear();
// ecoResStorageDimensionGroupProduct.initValue();
select forUpdate RecId from ecoResStorageDimensionGroupProduct where ecoResStorageDimensionGroupProduct.Product == ecoResProductMaster.RecId;
ecoResStorageDimensionGroupProduct.StorageDimensionGroup = EcoResStorageDimensionGroup::findByDimensionGroupName(ecoResStorageDimensionGroupName).RecId;
// if (ecoResStorageDimensionGroupProduct.validateWrite())
// {
// ecoResStorageDimensionGroupProduct.update();
// }
//Tracking dimension group
// ecoResTrackingDimensionGroupProduct.clear();
// ecoResTrackingDimensionGroupProduct.initValue();
select forUpdate RecId from ecoResTrackingDimensionGroupProduct where ecoResTrackingDimensionGroupProduct.Product == ecoResProductMaster.RecId;
ecoResTrackingDimensionGroupProduct.TrackingDimensionGroup = EcoResTrackingDimensionGroup::findByDimensionGroupName(ecoResTrackingDimensionGroupName).RecId;
//if (ecoResTrackingDimensionGroupProduct.validateWrite())
// {
// ecoResTrackingDimensionGroupProduct.update();
// }
//Product modeling policy
// ecoResProductMasterModelingPolicy.clear();
// ecoResProductMasterModelingPolicy.initValue();
// ecoResProductMasterModelingPolicy.ProductMaster == ecoResProductMaster.RecId;
// if (ecoResProductMasterModelingPolicy.validateWrite())
// {
//ecoResProductMasterModelingPolicy.update();
// }
//Product translation
EcoResProductTranslation::createOrUpdateTranslation(ecoResProductMaster.RecId, ecoResProductName, ecoResDescription);
//Configuration
ecoResConfiguration = EcoResConfiguration::findByName(description);
if (!ecoResConfiguration)
{
// ecoResConfiguration.clear();
//ecoResConfiguration.initValue();
ecoResConfiguration.Name = description;
// ecoResConfiguration.update();
}
//Configuration assigned to product master
//ecoResProductMasterConfiguration.clear();
// ecoResProductMasterConfiguration.initValue();
select forupdate RecId from ecoResProductMasterConfiguration where ecoResProductMasterConfiguration.Configuration == ecoResConfiguration.RecId;
// ecoResProductMasterConfiguration.Configuration = ecoResConfiguration.RecId;
{
ecoResProductMasterConfiguration.Description = description;
ecoResProductMasterConfiguration.ConfigProductDimensionAttribute = EcoResProductDimensionAttribute::inventDimFieldId2DimensionAttributeRecId(fieldNum(InventDim, ConfigId));
ecoResProductMasterConfiguration.ConfigProductMaster = ecoResProductMaster.RecId;
// ecoResProductMasterConfiguration.update();
}
//Product variant
// ecoResDistinctProductVariant.clear();
// ecoResDistinctProductVariant.initValue();
ecoResDistinctProductVariant.DisplayProductNumber = EcoResProductNumberBuilderVariant::buildFromProductNumberAndDimensions(
ecoResProductMaster.productNumber(),
EcoResProductVariantDimValue::getDimensionValuesContainer(description, "", ""));
ecoResDistinctProductVariant.SearchName = ecoResProductMaster.SearchName + ecoResProductSearchName/*ConfigId*/;
ecoResDistinctProductVariant.ProductType = ecoResProductMaster.ProductType;
ecoResDistinctProductVariant.ProductMaster = ecoResDistinctProductVariant::find(ecoResProductMaster.RecId).ProductMaster;
// ecoResDistinctProductVariant.update();
//Product variant configuration
// ecoResProductVariantConfiguration.clear();
// ecoResProductVariantConfiguration.initValue();
ecoResProductVariantConfiguration.initFromDistinctProductVariant(ecoResDistinctProductVariant);
ecoResProductVariantConfiguration.ProductDimensionAttribute = EcoResProductDimensionAttribute::inventDimFieldId2DimensionAttributeRecId(fieldNum(InventDim, ConfigId));
ecoResProductVariantConfiguration.Configuration = ecoResConfiguration.RecId;
// ecoResProductVariantConfiguration.update();
//Product variant translation
EcoResProductTranslation::createOrUpdateTranslation(ecoResDistinctProductVariant.RecId, ecoResProductName, ecoResDescription);
}
//Released product
// inventTable.clear();
// inventTable.initValue();
inventTable.initFromEcoResProduct(ecoResProductMaster);
select forupdate RecId from inventTable where inventTable.ItemId == ecoResProductDisplayProductNumber;
{
inventTable.NameAlias = ecoResProductSearchName;
// if (inventTable.validateWrite())
// {
// inventTable.update();
}
//Inventory model group
// inventModelGroupItem.clear();
// inventModelGroupItem.initValue();
select forUpdate RecId from inventModelGroupItem where inventModelGroupItem.ItemId == inventTable.ItemId;
{
inventModelGroupItem.ItemDataAreaId = inventTable.dataAreaId;
//inventModelGroupItem.ItemId = inventTable.ItemId;
inventModelGroupItem.ModelGroupId = "FIFO";
inventModelGroupItem.ModelGroupDataAreaId = curext();
// inventModelGroupItem.update();
}
//Item group
// inventItemGroupItem.clear();
//inventItemGroupItem.initValue();
select forUpdate RecId from inventItemGroupItem where inventItemGroupItem.ItemId == inventTable.ItemId;
{
inventItemGroupItem.ItemDataAreaId = inventTable.dataAreaId;
//inventItemGroupItem.ItemId = inventTable.ItemId;
inventItemGroupItem.ItemGroupId = "Parts";
inventItemGroupItem.ItemGroupDataAreaId = curext();
// inventItemGroupItem.update();
}
//Extended product details - Inventory
// inventTableModule.clear();
// inventTableModule.initValue();
select forUpdate RecId from inventTableModule where inventTableModule.ItemId == inventTable.ItemId;
{
inventTableModule.ModuleType = ModuleInventPurchSales::Invent;
// inventTableModule.update();
}
//Extended product details - Purchase
// inventTableModule.clear();
// inventTableModule.initValue();
select forUpdate RecId from inventTableModule where inventTableModule.ItemId == inventTable.ItemId;
{
inventTableModule.ModuleType = ModuleInventPurchSales::Purch;
// inventTableModule.update();
}
//Extended product details - Sales
// inventTableModule.clear();
// inventTableModule.initValue();
select forUpdate RecId from inventTableModule where inventTableModule.ItemId == inventTable.ItemId;
{
inventTableModule.ModuleType = ModuleInventPurchSales::Sales;
// inventTableModule.update();
}
//Warehouse items
InventItemLocation::findDefault(inventTable.ItemId);
//Supply type setup
//inventItemSetupSupplyType.clear();
//inventItemSetupSupplyType.initValue();
select forUpdate RecId from inventItemSetupSupplyType where inventItemSetupSupplyType.ItemId == inventTable.ItemId;
{
inventItemSetupSupplyType.ItemDataAreaId = inventTable.DataAreaId;
// inventItemSetupSupplyType.update();
}
//Product storage dimension group
ecoResStorageDimensionGroupProduct = EcoResStorageDimensionGroupProduct::findByProduct(ecoResProductMaster.RecId);
if (ecoResStorageDimensionGroupProduct.RecId)
{
//ecoResStorageDimensionGroupItem.clear();
// ecoResStorageDimensionGroupItem.initValue();
select forUpdate RecId from ecoResStorageDimensionGroupItem where ecoResStorageDimensionGroupItem.ItemId == inventTable.ItemId;
{
ecoResStorageDimensionGroupItem.ItemDataAreaId = inventTable.DataAreaId;
// ecoResStorageDimensionGroupItem.ItemId = inventTable.ItemId;
ecoResStorageDimensionGroupItem.StorageDimensionGroup = ecoResStorageDimensionGroupProduct.StorageDimensionGroup;
// ecoResStorageDimensionGroupItem.update();
}
}
//Product tracking dimension group
ecoResTrackingDimensionGroupProduct = EcoResTrackingDimensionGroupProduct::findByProduct(ecoResProductMaster.RecId);
if (ecoResTrackingDimensionGroupProduct.RecId)
{
//ecoResTrackingDimensionGroupItem.clear();
// ecoResTrackingDimensionGroupItem.initValue();
select forUpdate RecId from ecoResTrackingDimensionGroupItem where ecoResTrackingDimensionGroupItem.ItemId == inventTable.ItemId;
ecoResTrackingDimensionGroupItem.ItemDataAreaId = inventTable.DataAreaId;
// ecoResTrackingDimensionGroupItem.ItemId = inventTable.ItemId;
ecoResTrackingDimensionGroupItem.TrackingDimensionGroup = ecoResTrackingDimensionGroupProduct.TrackingDimensionGroup;
// ecoResTrackingDimensionGroupItem.update();
}
// }
// inventDim.clear();
inventDim.ConfigId = description;/*ConfigId*/
inventDim = InventDim::findOrCreate(inventDim);
//Released product variant
// inventDimCombination.clear();
// inventDimCombination.initValue();
inventDimCombination.DistinctProductVariant = inventDimCombination::findByDistinctProductVariant(ecoResDistinctProductVariant.RecId).DistinctProductVariant;
select forupdate RecId from inventDimCombination where inventDimCombination.ItemId == inventTable.ItemId;
{
inventDimCombination.InventDimId = inventDim.InventDimId;
//inventDimCombination.update();
}
}
//}
catch
{
error("Error!");
return;
}
info("Import completed !");
}
No comments:
Post a Comment