Upload NumberSequence using x++ :
static
void Addit_Upload_FA_Numseq(Args _args)
{
NumberSequenceTable numberSeqTable;
NumberSequenceScope numberSeqScope;
container segments;
str
annotatedFormat, format;
FileNameFilter filter;
Dialog dialog;
DialogField field;
FilenameOpen filenameOpen;
COMVariant COMVariant;
COMVariantType type;
SysExcelApplication app;
SysExcelWorkbooks Workbooks;
SysExcelWorkbook Workbook;
SysExcelWorksheets Worksheets;
SysExcelWorksheet Worksheet1, Worksheet2;
SysExcelCells Cells;
SysExcelCell Cell;
int row,j;
#excel
;
filter =
["*.xlsx","*.xls"];
dialog = new Dialog("Choose
Excel");
field =
dialog.addField(extendedTypeStr(filenameOpen), "File Name");
dialog.run();
if (dialog.closedOK())
{
app =
SysExcelApplication::construct();
Workbooks = app.Workbooks();
COMVariant = new COMVariant();
COMVariant.bStr(field.value());
Workbook = Workbooks.Add(COMVariant);
Worksheets = Workbook.worksheets();
Worksheet1 =
Worksheets.itemFromNum(1);
Cells = Worksheet1.Cells();
}
// Purchase Order Header pada sheet 1
Worksheet1 = Worksheets.itemFromNum(1);
Cells = Worksheet1.cells();
row
= 2;
type = cells.item(row,
1).value().variantType();
ttsBegin;
while (Cells.item(row,
2).value().variantType() != COMVariantType::VT_EMPTY)
{
select
numberSeqScope
where numberSeqScope.DataArea
== 'BSP';
segments = conNull();
segments += [[-1, cells.item(row,
1).value().bStr()]];
segments += [[-2, cells.item(row,
6).value().bStr()]];
annotatedFormat = NumberSeq::createAnnotatedFormatFromSegments(segments);
//format =
NumberSeq::createAnnotatedFormatFromSegments(segments, false);
numberSeqTable.clear();
numberSeqTable.NumberSequence = cells.item(row, 1).value().bStr();
numberSeqTable.Txt = cells.item(row,
7).value().bStr();
numberSeqTable.AnnotatedFormat = annotatedFormat;
numberSeqTable.NumberSequenceScope = numberSeqScope.RecId;
numberSeqTable.Format = cells.item(row,
5).value().bStr() + cells.item(row,
6).value().bStr();
numberSeqTable.Continuous = NoYes::Yes;
numberSeqTable.Highest = 999;
numberSeqTable.Lowest = 1;
numberSeqTable.NextRec = 1;
if(cells.item(row, 1).value().bStr() !=
'')
{
row++;
type = cells.item(row,
1).value().variantType();
numberSeqTable.insert();
}
}
ttsCommit;
info("Asset Group 30 Group has been
finished");
}
0 comments:
Post a Comment