static void FS_Load_Standard_Cost_DB(Args _args)
{
//scapistrant-20100903
//Mods 2010-12-29 per DBucher
inventitempricesim inventitempricesim;
FileName fileName;
SysExcelApplication excelApp;
boolean rowFound = true;
boolean TrueFalse = true;
counter readCounter = 0;
counter ErrCounter = 0;
counter InsertCounter = 0;
counter updateCounter = 0;
Itemid fsName;
int lineNum = 4;
int lineNumEnd = 999999;
Dialog dialog;
DialogField dialogFieldFileName;
DialogField dialogFieldStartLineNum;
DialogField dialogFieldEndLineNum;
DialogField dialogFieldInventDimId;
SysOperationProgress progress = new SysOperationProgress();
#AviFiles
;
progress.setAnimation(#AviUpdate);
progress.setCaption("Load Standard Cost into InventItemPriceSim");
dialog = new Dialog('Load Standard Price into InventItemPriceSim table');
dialogFieldFileName = dialog.addField(typeId(FileNameOpen), 'File name', 'Filename containing input data');
dialogFieldFileName.lookupButton(2);
dialogFieldStartLineNum = dialog.addField(typeid(Integer),"Starting Liine Number","start loading records at line number specified");
dialogFieldStartLineNum.value(lineNum);
dialogFieldEndLineNum = dialog.addField(typeid(Integer),"Ending Liine Number","stop loading records at line number specified");
dialogFieldEndLineNum.value(lineNumEnd);
dialogFieldInventDimId = dialog.addField(typeid(inventDimId),"Enter InventDimId relating to InventDimTable filtered by Site ID for AE");
if (dialog.run())
{
fileName = dialogFieldFileName.value();
if(!fileName)
{
info(strfmt('No file name specified'));
return;
}
if (dialogFieldStartLineNum.value() > 0)
{
lineNum = dialogFieldStartLineNum.value();
}
if (dialogFieldEndLineNum.value() > 0)
{
lineNumEnd = dialogFieldEndLineNum.value();
}
ExcelApp = SysExcelApplication::construct();
ExcelApp.workbooks().open(filename);
try
{
while (rowFound && ExcelApp.activeSheet().cells().range(strfmt('A%1',lineNum)).item(lineNum))
{
readCounter++;
if (lineNum > lineNumEnd)
{
rowfound = false;
continue;
}
if (ExcelApp.activeSheet().cells().item(lineNum, 1).value().variantType() == ComVariantType::VT_EMPTY &&
ExcelApp.activeSheet().cells().item(lineNum, 2).value().variantType() == ComVariantType::VT_EMPTY)
{
rowfound = false;
continue;
}
//load data
ttsbegin;
//values provided by Jeffery
//inventItemPriceSim.ItemId = ExcelApp.activeSheet().cells().item(lineNum, 1).value().bstr();
if (ExcelApp.activeSheet().cells().item(lineNum, 1).value().varianttype() == comVariantType::VT_R8)
{
inventItemPriceSim.ItemId = num2str(ExcelApp.activeSheet().cells().item(lineNum, 1).value().double(),0,0,2,0);//item ID-verify both
}
else
{
inventItemPriceSim.ItemId = ExcelApp.activeSheet().cells().item(lineNum, 1).value().bstr(); //item ID-verify both
}
info(ExcelApp.activeSheet().cells().item(lineNum, 1).value().bstr());
info(num2str(ExcelApp.activeSheet().cells().item(lineNum, 1).value().double(),0,0,2,0));
inventItemPriceSim.VersionId = "Std-2011fe"; //verify from accounting
inventItemPriceSim.FromDate = str2date("01-31-2011",213); // verify with acconting
inventItemPriceSim.PriceType = CostingVersionPriceType::Cost; // never change
inventItemPriceSim.Price = ExcelApp.activeSheet().cells().item(lineNum, 3).value().double(); //unit price
inventItemPriceSim.PriceUnit = 1; // always a 1
inventItemPriceSim.UnitID = ExcelApp.activeSheet().cells().item(lineNum, 2).value().bstr(); //unit of measure
inventItemPriceSim.InventDimId = dialogFieldInventDimId.value(); //never changes
inventItemPriceSim.insert();
ttscommit;
InsertCounter ++;
lineNum ++;
}
}
catch
{
excelapp.workbooks().close();
excelapp.quit();
info(strfmt('Error occured at rcd %1 for Item: %2', lineNum, fsName));
}
info("Records Read " + int2str(readCounter));
info("Records Inserted " + int2str(insertCounter));
}
return;
}
{
//scapistrant-20100903
//Mods 2010-12-29 per DBucher
inventitempricesim inventitempricesim;
FileName fileName;
SysExcelApplication excelApp;
boolean rowFound = true;
boolean TrueFalse = true;
counter readCounter = 0;
counter ErrCounter = 0;
counter InsertCounter = 0;
counter updateCounter = 0;
Itemid fsName;
int lineNum = 4;
int lineNumEnd = 999999;
Dialog dialog;
DialogField dialogFieldFileName;
DialogField dialogFieldStartLineNum;
DialogField dialogFieldEndLineNum;
DialogField dialogFieldInventDimId;
SysOperationProgress progress = new SysOperationProgress();
#AviFiles
;
progress.setAnimation(#AviUpdate);
progress.setCaption("Load Standard Cost into InventItemPriceSim");
dialog = new Dialog('Load Standard Price into InventItemPriceSim table');
dialogFieldFileName = dialog.addField(typeId(FileNameOpen), 'File name', 'Filename containing input data');
dialogFieldFileName.lookupButton(2);
dialogFieldStartLineNum = dialog.addField(typeid(Integer),"Starting Liine Number","start loading records at line number specified");
dialogFieldStartLineNum.value(lineNum);
dialogFieldEndLineNum = dialog.addField(typeid(Integer),"Ending Liine Number","stop loading records at line number specified");
dialogFieldEndLineNum.value(lineNumEnd);
dialogFieldInventDimId = dialog.addField(typeid(inventDimId),"Enter InventDimId relating to InventDimTable filtered by Site ID for AE");
if (dialog.run())
{
fileName = dialogFieldFileName.value();
if(!fileName)
{
info(strfmt('No file name specified'));
return;
}
if (dialogFieldStartLineNum.value() > 0)
{
lineNum = dialogFieldStartLineNum.value();
}
if (dialogFieldEndLineNum.value() > 0)
{
lineNumEnd = dialogFieldEndLineNum.value();
}
ExcelApp = SysExcelApplication::construct();
ExcelApp.workbooks().open(filename);
try
{
while (rowFound && ExcelApp.activeSheet().cells().range(strfmt('A%1',lineNum)).item(lineNum))
{
readCounter++;
if (lineNum > lineNumEnd)
{
rowfound = false;
continue;
}
if (ExcelApp.activeSheet().cells().item(lineNum, 1).value().variantType() == ComVariantType::VT_EMPTY &&
ExcelApp.activeSheet().cells().item(lineNum, 2).value().variantType() == ComVariantType::VT_EMPTY)
{
rowfound = false;
continue;
}
//load data
ttsbegin;
//values provided by Jeffery
//inventItemPriceSim.ItemId = ExcelApp.activeSheet().cells().item(lineNum, 1).value().bstr();
if (ExcelApp.activeSheet().cells().item(lineNum, 1).value().varianttype() == comVariantType::VT_R8)
{
inventItemPriceSim.ItemId = num2str(ExcelApp.activeSheet().cells().item(lineNum, 1).value().double(),0,0,2,0);//item ID-verify both
}
else
{
inventItemPriceSim.ItemId = ExcelApp.activeSheet().cells().item(lineNum, 1).value().bstr(); //item ID-verify both
}
info(ExcelApp.activeSheet().cells().item(lineNum, 1).value().bstr());
info(num2str(ExcelApp.activeSheet().cells().item(lineNum, 1).value().double(),0,0,2,0));
inventItemPriceSim.VersionId = "Std-2011fe"; //verify from accounting
inventItemPriceSim.FromDate = str2date("01-31-2011",213); // verify with acconting
inventItemPriceSim.PriceType = CostingVersionPriceType::Cost; // never change
inventItemPriceSim.Price = ExcelApp.activeSheet().cells().item(lineNum, 3).value().double(); //unit price
inventItemPriceSim.PriceUnit = 1; // always a 1
inventItemPriceSim.UnitID = ExcelApp.activeSheet().cells().item(lineNum, 2).value().bstr(); //unit of measure
inventItemPriceSim.InventDimId = dialogFieldInventDimId.value(); //never changes
inventItemPriceSim.insert();
ttscommit;
InsertCounter ++;
lineNum ++;
}
}
catch
{
excelapp.workbooks().close();
excelapp.quit();
info(strfmt('Error occured at rcd %1 for Item: %2', lineNum, fsName));
}
info("Records Read " + int2str(readCounter));
info("Records Inserted " + int2str(insertCounter));
}
return;
}
No comments:
Post a Comment