We
have to follow some steps:-
Step
1:
Create
a Table(ImportOption) with some fields.TransferId is one of the field
which is mandatory.
Step
2:
Create
a relation for TransferId with InventTransferTable.Set the
Relation properties as follows..
Step
3:
Add
Table as datasource into form(ImportOption).drag and drop the fields
into design node.
Step
4:
Now
add the form into Menuitem-->display node in AOT.
Step
5:
Create
an Excel file with records which we need to import into ImportOption
table.
Step
6:
Convert
the excel file into CSV file(file-->save
as-->Filename-->Book1-->Type-->CSV (comma delimited).
Step
7:
Create
the MenuItemButton in the Action pane of the InventTransferOrder (or)
CopyofinventTransferOrder form.
Step
8:
Now
set the property menuItemName for that menuitembutton is
ImportOption.
Step
9:
Under
the menuitembutton write the clicked() method with following code,
void
clicked()
{
Dialog dialog;
DialogField
dialogFileName;
SysOperationProgress
simpleProgress;
Filename
filename;
FileIOPermission
permission;
TextIO
textIO;
ImportOption
importOption;
InventTransferTable
iinventTransferTable;
str
itemname,transferid;
real
qty;
str
s11;
int
i;
Container
c1,c2;
CompanyInfo
companyInfoLoc = CompanyInfo::find();
Container
filterCriteria;
#File
#avifiles
super();
dialog
= new
Dialog("Importing
Text File");
dialogFileName
= dialog.addField(extendedTypeStr(Filenameopen),
"File
Name");
filterCriteria
= ['*.txt'];
filterCriteria
= dialog.filenameLookupFilter(filterCriteria);
dialog.run();
if
(dialog.run())
filename
= dialogFileName.value();
if(!filename)
{
info("Filename
must be filled");
}
permission
= new
fileIOpermission(filename,#io_read);
permission.assert();
textIO
= new
TextIO(filename,#io_read);
textIO.inFieldDelimiter(',');///Change
the Delimeter if it is , or ; etc
simpleProgress
= SysOperationProgress::newGeneral(#aviUpdate, 'Importing
data',100);
if(textIO)
{
while(textIO.status()
== IO_Status::Ok)
{
c1
= textIO.read();
s11
= conpeek(c1,3);
if(strlen(s11)
> 1)
{
select
importOption ;
importOption.Qty=conPeek(c1,1);
importOption.ItemName=conPeek(c1,2);
importOption.TransferIdentity=conPeek(c1,3);
importOption.insert();
i++;
simpleProgress.incCount();
simpleprogress.setText(strfmt("Lines
imported: %1",
i));
sleep(10);
}
}
}
}
Step
10:
This
code used to import records from csv file.
If
you want to modify records in csv files then right click the csv
file-->open with -->notepad.Here change the records and save
it.
Finally We get the output....