Delete Release Product using x++ :
static void ProductDeletion(Args _args)
{
InventTable inventTable;
BOMVersion bomVersion;
EcoResProduct ecoResProduct;
//Read Excel file
SysExcelApplication excel;
SysExcelWorkbooks workbooks;
SysExcelWorkbook workbook;
SysExcelWorksheets worksheets;
SysExcelWorksheet worksheet;
SysExcelCells cells;
COMVariantType type;
int row;
str 100 itemID;
#define.filename(@'C:\temp\PartListForDeletion.xlsx')
excel = SysExcelApplication::construct();
workbooks = excel.workbooks();
try
{
workbooks.open(#filename);
}
catch (Exception::Error)
{
throw error("File cannot be opened");
}
workbook = workbooks.item(1);
worksheets = workbook.worksheets();
worksheet = worksheets.itemFromNum(1);
cells = worksheet.cells();
type = cells.item(row+1, 1).value().variantType();
while (type != COMVariantType::VT_EMPTY)
{
row++;
itemID = cells.item(row, 1).value().bStr();
//Delete Item
while select forUpdate inventTable
where inventTable.ItemId == itemID
{
if(inventTable.validateDelete())
{
ttsBegin;
InventTable.delete();
ttsCommit;
}
else
{
cells.item(row, 2).value(infolog.text());
cells.item(1, 4).value("Error Found, Please Investigate.");
}
infolog.clear();
}
while select forUpdate EcoResProduct
where EcoResProduct.DisplayProductNumber == itemID
{
if(EcoResProduct.validateDelete())
{
ttsBegin;
EcoResProduct.delete();
ttsCommit;
}
else
{
cells.item(row, 3).value(infolog.text());
cells.item(1, 4).value("Error Found, Please Investigate.");
}
infolog.clear();
}
type = cells.item(row+1, 1).value().variantType();
}
cells.item(1, 6).value("Deletion Done!");
excel.visible(true);
}
static void ProductDeletion(Args _args)
{
InventTable inventTable;
BOMVersion bomVersion;
EcoResProduct ecoResProduct;
//Read Excel file
SysExcelApplication excel;
SysExcelWorkbooks workbooks;
SysExcelWorkbook workbook;
SysExcelWorksheets worksheets;
SysExcelWorksheet worksheet;
SysExcelCells cells;
COMVariantType type;
int row;
str 100 itemID;
#define.filename(@'C:\temp\PartListForDeletion.xlsx')
excel = SysExcelApplication::construct();
workbooks = excel.workbooks();
try
{
workbooks.open(#filename);
}
catch (Exception::Error)
{
throw error("File cannot be opened");
}
workbook = workbooks.item(1);
worksheets = workbook.worksheets();
worksheet = worksheets.itemFromNum(1);
cells = worksheet.cells();
type = cells.item(row+1, 1).value().variantType();
while (type != COMVariantType::VT_EMPTY)
{
row++;
itemID = cells.item(row, 1).value().bStr();
//Delete Item
while select forUpdate inventTable
where inventTable.ItemId == itemID
{
if(inventTable.validateDelete())
{
ttsBegin;
InventTable.delete();
ttsCommit;
}
else
{
cells.item(row, 2).value(infolog.text());
cells.item(1, 4).value("Error Found, Please Investigate.");
}
infolog.clear();
}
while select forUpdate EcoResProduct
where EcoResProduct.DisplayProductNumber == itemID
{
if(EcoResProduct.validateDelete())
{
ttsBegin;
EcoResProduct.delete();
ttsCommit;
}
else
{
cells.item(row, 3).value(infolog.text());
cells.item(1, 4).value("Error Found, Please Investigate.");
}
infolog.clear();
}
type = cells.item(row+1, 1).value().variantType();
}
cells.item(1, 6).value("Deletion Done!");
excel.visible(true);
}
0 comments:
Post a Comment