you can't insert any records directly to any abstract class, in the same way as you can't directly instantiate any abstract class. What you can do is to insert data to a concrete child of the abstract table (again, you can see the similarity with classes).
EcoResProduct has three children:
EcoResDistinctProduct, EcoResDistinctProductVariant and EcoResProductMaster.
Write Below Job For this:-
static void RecordsImports(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;
PdsCWProduct pdsCWProduct;
EcoResProductDisplayProductNumber ecoResProductDisplayProductNumber;
EcoResProductSearchName ecoResProductSearchName;
EcoResProductType ecoResProductType;
EcoResDistinctProduct ecoResDistinctProduct;
EcoResDistinctProductVariant ecoResDistinctProductVariant;
EcoResProductMaster ecoResProductMaster;
;
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();
ecoResDistinctProduct.DisplayProductNumber = ecoResProductDisplayProductNumber;
ecoResDistinctProduct.PdsCWProduct = pdsCWProduct;
ecoResDistinctProduct.ProductType = ecoResProductType;
ecoResDistinctProduct.SearchName = ecoResProductSearchName;
ecoResDistinctProductVariant.DisplayProductNumber = ecoResProductDisplayProductNumber;
ecoResDistinctProductVariant.PdsCWProduct = pdsCWProduct;
ecoResDistinctProductVariant.ProductType = ecoResProductType;
ecoResDistinctProductVariant.SearchName = ecoResProductSearchName;
ecoResProductMaster.DisplayProductNumber = ecoResProductDisplayProductNumber;
ecoResProductMaster.PdsCWProduct = pdsCWProduct;
ecoResProductMaster.ProductType = ecoResProductType;
ecoResProductMaster.SearchName = ecoResProductSearchName;
ecoResProductMaster.insert();
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 ");
}
}
EcoResProduct has three children:
EcoResDistinctProduct, EcoResDistinctProductVariant and EcoResProductMaster.
Write Below Job For this:-
static void RecordsImports(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;
PdsCWProduct pdsCWProduct;
EcoResProductDisplayProductNumber ecoResProductDisplayProductNumber;
EcoResProductSearchName ecoResProductSearchName;
EcoResProductType ecoResProductType;
EcoResDistinctProduct ecoResDistinctProduct;
EcoResDistinctProductVariant ecoResDistinctProductVariant;
EcoResProductMaster ecoResProductMaster;
;
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();
ecoResDistinctProduct.DisplayProductNumber = ecoResProductDisplayProductNumber;
ecoResDistinctProduct.PdsCWProduct = pdsCWProduct;
ecoResDistinctProduct.ProductType = ecoResProductType;
ecoResDistinctProduct.SearchName = ecoResProductSearchName;
ecoResDistinctProductVariant.DisplayProductNumber = ecoResProductDisplayProductNumber;
ecoResDistinctProductVariant.PdsCWProduct = pdsCWProduct;
ecoResDistinctProductVariant.ProductType = ecoResProductType;
ecoResDistinctProductVariant.SearchName = ecoResProductSearchName;
ecoResProductMaster.DisplayProductNumber = ecoResProductDisplayProductNumber;
ecoResProductMaster.PdsCWProduct = pdsCWProduct;
ecoResProductMaster.ProductType = ecoResProductType;
ecoResProductMaster.SearchName = ecoResProductSearchName;
ecoResProductMaster.insert();
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 ");
}
}
No comments:
Post a Comment