static void POConfirmCode(Args _args)
{
SysExcelApplication xlsApplication;
SysExcelWorkBooks xlsWorkBookCollection;
SysExcelWorkBook xlsWorkBook;
SysExcelWorksheets xlsWorkSheetCollection;
SysExcelWorksheet xlsWorkSheet;
SysExcelRange xlsRange;
SysExcelCells Cells;
SysExcelCell RCell;
CommaIO inFile;
#define.ExampleOpenMode("r")
int nRow,i;
DialogField dialogPath;
Dialog dialog;
Filename filename;
Name Name;
PurchFormLetter purchFormLetter;
PurchFormletterParmData purchFormLetterParmData;
PurchParmUpdate purchParmUpdate;
PurchParmTable purchParmTable;
PurchParmLine purchParmLine;
PurchTable purchTable;
PurchLine purchLine;
PurchId purchId;
Num packingSlipId;
;
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() != "")
{
purchId = RCell.value().bStr();
purchTable = PurchTable::find(purchId);
ttsBegin;
// Create PurchParamUpdate table
purchFormLetterParmData = PurchFormletterParmData::newData(
DocumentStatus::PurchaseOrder,
VersioningUpdateType::Initial);
purchFormLetterParmData.parmOnlyCreateParmUpdate(true);
purchFormLetterParmData.createData(false);
purchParmUpdate = purchFormLetterParmData.parmParmUpdate();
// Set PurchParmTable table
purchParmTable.clear();
purchParmTable.TransDate = SystemDateGet();
purchParmTable.DocumentDate = SystemDateGet();
purchParmTable.Ordering = DocumentStatus::PurchaseOrder;
purchParmTable.ParmJobStatus = ParmJobStatus::Waiting;
purchParmTable.PurchId = purchTable.PurchId;
purchParmTable.PurchName = purchTable.PurchName;
purchParmTable.DeliveryName = purchTable.DeliveryName;
purchParmTable.DeliveryPostalAddress = purchTable.DeliveryPostalAddress;
purchParmTable.OrderAccount = purchTable.OrderAccount;
purchParmTable.CurrencyCode = purchTable.CurrencyCode;
purchParmTable.InvoiceAccount = purchTable.InvoiceAccount;
purchParmTable.ParmId = purchParmUpdate.ParmId;
purchParmTable.insert();
purchFormLetter = PurchFormLetter::construct(DocumentStatus::PurchaseOrder);
purchFormLetter.transDate(systemDateGet());
purchFormLetter.proforma(false);
purchFormLetter.specQty(PurchUpdate::All);
purchFormLetter.purchTable(purchTable);
// This is the ID we hard code as the product receipt ID, if we do the posting via UI
// user would have the option to manually enter this value
purchFormLetter.parmParmTableNum(purchParmTable.ParmId);
purchFormLetter.parmId(purchParmTable.ParmId);
purchFormLetter.purchParmUpdate(purchFormLetterParmData.parmParmUpdate());
purchFormLetter.run();
ttsCommit;
nRow++;
// info(strFmt("%1", counte));
// counte = 0;
RCell = Cells.Item(nRow, 1);
}
xlsApplication.quit ();
xlsApplication.finalize ();
info("Import completed");
}
catch( Exception::Error)
{
xlsApplication.quit ();
xlsApplication.finalize ();
ttsabort;
info("Unable to process the excel import");
}
}
{
SysExcelApplication xlsApplication;
SysExcelWorkBooks xlsWorkBookCollection;
SysExcelWorkBook xlsWorkBook;
SysExcelWorksheets xlsWorkSheetCollection;
SysExcelWorksheet xlsWorkSheet;
SysExcelRange xlsRange;
SysExcelCells Cells;
SysExcelCell RCell;
CommaIO inFile;
#define.ExampleOpenMode("r")
int nRow,i;
DialogField dialogPath;
Dialog dialog;
Filename filename;
Name Name;
PurchFormLetter purchFormLetter;
PurchFormletterParmData purchFormLetterParmData;
PurchParmUpdate purchParmUpdate;
PurchParmTable purchParmTable;
PurchParmLine purchParmLine;
PurchTable purchTable;
PurchLine purchLine;
PurchId purchId;
Num packingSlipId;
;
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() != "")
{
purchId = RCell.value().bStr();
purchTable = PurchTable::find(purchId);
ttsBegin;
// Create PurchParamUpdate table
purchFormLetterParmData = PurchFormletterParmData::newData(
DocumentStatus::PurchaseOrder,
VersioningUpdateType::Initial);
purchFormLetterParmData.parmOnlyCreateParmUpdate(true);
purchFormLetterParmData.createData(false);
purchParmUpdate = purchFormLetterParmData.parmParmUpdate();
// Set PurchParmTable table
purchParmTable.clear();
purchParmTable.TransDate = SystemDateGet();
purchParmTable.DocumentDate = SystemDateGet();
purchParmTable.Ordering = DocumentStatus::PurchaseOrder;
purchParmTable.ParmJobStatus = ParmJobStatus::Waiting;
purchParmTable.PurchId = purchTable.PurchId;
purchParmTable.PurchName = purchTable.PurchName;
purchParmTable.DeliveryName = purchTable.DeliveryName;
purchParmTable.DeliveryPostalAddress = purchTable.DeliveryPostalAddress;
purchParmTable.OrderAccount = purchTable.OrderAccount;
purchParmTable.CurrencyCode = purchTable.CurrencyCode;
purchParmTable.InvoiceAccount = purchTable.InvoiceAccount;
purchParmTable.ParmId = purchParmUpdate.ParmId;
purchParmTable.insert();
purchFormLetter = PurchFormLetter::construct(DocumentStatus::PurchaseOrder);
purchFormLetter.transDate(systemDateGet());
purchFormLetter.proforma(false);
purchFormLetter.specQty(PurchUpdate::All);
purchFormLetter.purchTable(purchTable);
// This is the ID we hard code as the product receipt ID, if we do the posting via UI
// user would have the option to manually enter this value
purchFormLetter.parmParmTableNum(purchParmTable.ParmId);
purchFormLetter.parmId(purchParmTable.ParmId);
purchFormLetter.purchParmUpdate(purchFormLetterParmData.parmParmUpdate());
purchFormLetter.run();
ttsCommit;
nRow++;
// info(strFmt("%1", counte));
// counte = 0;
RCell = Cells.Item(nRow, 1);
}
xlsApplication.quit ();
xlsApplication.finalize ();
info("Import completed");
}
catch( Exception::Error)
{
xlsApplication.quit ();
xlsApplication.finalize ();
ttsabort;
info("Unable to process the excel import");
}
}
No comments:
Post a Comment