static void
BOMActive(Args _args)
{
Dialog dialog = new
Dialog();
LedgerJournalName _LedgerJournalName;
str _BusinessUnit,_Account ;
NumberSeq _numberSeq;
int
num;
BOMTable _BOMTable,_BOMTable1,
_BOMTable2;
BOM _BOM,_BOM1,_BOM2;
EcoResProductMaster _EcoResProductMaster;
EcoResProductMasterColor
_EcoResProductMasterColor;
EcoResColor _EcoResColor;
BOMVersion
_BOMVersion,_BOMVersion1,_BOMVersion2;
InventDim inventDim, _inventDim1,
inventDimNew,_InventDim,_invtdim;
ReqItemTable _ReqItemTable, _ReqItemTable1,
_ReqItemTable_check;
InventTableModule _InventTableModule;
InventTable _inventTable;
InventSum _inventSum;
InventPosting _inventposting;
str
dimid;
DialogField dialogField,typeofJournal;
RecId
a ;
container
offsetDimensions;
Voucher _Voucher;
CustLedgerAccounts _custLegerAccount, _custLegerAccount1;
DimensionAttributeValueCombination
_DimensionAttributeValueCombination,_DimensionAttributeValueCombination1;
RecId
_RecId;
AsciiIo importFile,logFile;
str
filePath,fileNameOnly;
LedgerJournalTable _LedgerJournalTable;
LedgerJournalTrans _LedgerJournalTrans;
Currency _Currency;
LedgerVoucher _LedgerVoucher;
int
rowcount;
NumberSequence _NumberSequence;
//filetype
type;
container
record;
SysExcelApplication xlsApplication;
SysExcelApplication application;
SysExcelWorkbooks workbooks;
InventTrans _InventTrans;
InventTransOrigin _InventTransOrigin;
SysExcelWorkbook workbook;
SysExcelWorksheets worksheets;
SysExcelWorksheet worksheet;
SysExcelWorkBooks xlsWorkBookCollection;
SysExcelWorkBook xlsWorkBook;
SysExcelWorkSheets xlsWorkSheetCollection;
SysExcelWorkSheet xlsWorkSheet;
SysExcelRange xlsRange;
NumberSequenceTable _NumberSequenceTable;
SysOperationProgress progress = new SysOperationProgress() ;
LedgerJournalTransTaxExtensionIN _LedgerJournalTransTaxExtensionIN;
SysExcelCells cells;
str Item;
COMVariantType type;
int
totalRecords, totalInserted,totalFail,x,srNum,row;
str
NewFileName,FileName,billNo,Segment,NewJournalNum,NewJournalNum1, change;
int
journalnum ;
real
LRNo;
str 20 approver1 = '1154';//Approver User ID
BOMApprove bomApprove = new BOMApprove();
RecId approver =
HcmWorker::findByPersonnelNumber(approver1).RecId;
BOMId bomid
;
dialogField=dialog.addField(extendedTypeStr(FilenameOpen),"Select File","Select
file to import");
dialog.caption("Select
File To Import");
row=2;
application =
SysExcelApplication::construct();
workbooks = application.workbooks();
if(!dialog.run())
return;
[filePath, fileNameOnly, type] =
fileNameSplit(dialogField.value());
FileName=dialogField.value();
NewFileName=strReplace(FileName,@"\",@"\\");
try
{
workbooks.open(NewFileName);
}
catch
(Exception::Error)
{
throw
error("File cannot be opened.");
}
workbook = workbooks.item(1);
worksheets = workbook.worksheets();
worksheet = worksheets.itemFromNum(1);
cells = worksheet.cells();
x=2;
srNum=1;
while(cells.item(row,1).value().bStr()!="")
{
//_BOMTable
= BOMTable::find(cells.item(row,1).value().bStr());
bomid = cells.item(row,1).value().bStr();
select
forUpdate _BOMVersion where _BOMVersion.BOMId==bomid;
_BOMVersion.Approved = true;
_BOMVersion.Active = true;
_BOMVersion.Approver = approver;
ttsBegin;
_BOMVersion.write();
ttsCommit;
bomApprove.init();
bomApprove.parmApprover(approver);
bomApprove.parmBOMId(bomid);
bomApprove.run();
row++;
}
info(strFmt("Upload Successfully"));
}
No comments:
Post a Comment