static void
JournalNumbersUpdate2009(Args _args)
{
SysExcelApplication application;
SysExcelWorkbooks workbooks;
SysExcelWorkbook workbook;
SysExcelWorksheets worksheets;
SysExcelWorksheet worksheet;
SysExcelCells cells;
COMVariantType type;
ledgerJournalid
oldjournalnum,newjournalnum;
int
row;
LedgerJournalTable journaltable;
LedgerJournalTrans journaltrans;
ledgertrans ledgertrans;
vendtrans vendtrans;
Filename
filename;
;
application = SysExcelApplication::construct();
workbooks
= application.workbooks();
//specify the file path that you want to read
filename
="C:\\JounralNumbersUpdate.xlsx";
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();
do
{
row++;
oldjournalnum = cells.item(row, 1).value().bStr();
newjournalnum = cells.item(row, 2).value().bStr();
ttsbegin;
while select
forupdate journaltable
where journaltable.JournalNum ==
oldjournalnum
{
journaltable.JournalNum = newjournalnum;
journaltable.doUpdate();
}
while select
forupdate journaltrans
where journaltrans.JournalNum ==
oldjournalnum
{
journaltrans.JournalNum = newjournalnum;
journaltrans.doUpdate();
}
while select
forupdate ledgertrans
where ledgertrans.JournalNum == oldjournalnum
{
ledgertrans.JournalNum = newjournalnum;
ledgertrans.doUpdate();
}
while select
forupdate vendtrans
where vendtrans.JournalNum == oldjournalnum
{
vendtrans.JournalNum = newjournalnum;
vendtrans.doUpdate();
}
ttscommit;
info(oldjournalnum + '-' +
newjournalnum);
type
= cells.item(row+1, 1).value().variantType();
}
while (type != COMVariantType::VT_EMPTY);
application.quit();
info("Done");
}
No comments:
Post a Comment