Search This Blog

Friday, 13 February 2015

X++ code to import data from text file(.txt) to Ax Tables in Ax 2009

Hi ,

Refer the below X++ code which import data from text file to Ax Tables in AX 2009
 
static void Notepad(Args _args)
{
FilenameOpen filename;
dialogField dialogFilename;
Dialog dialog;
TextIO file;
NotepadTable notepadTable;
container con;
str conitem,conitem1,conitem2;
int i;
#File
 
;

dialog = new Dialog("Notepad Upoad");
dialogFilename = dialog.addFieldValue(extendedTypeStr(FilenameOpen),filename,"File Name");
dialog.filenameLookupFilter([".txt", #AllFiles]);
dialog.filenameLookupTitle("Upload from Text File");
dialog.caption("Upload from text file");
dialogFilename.value(filename);
if(!dialog.run())
return;
filename = dialogFilename.value();
file = new TextIO(filename, #IO_READ);
file.inRecordDelimiter('\n'); //For Next Record
file.inFieldDelimiter('\t');
ttsbegin;
while(file.status() == IO_STATUS::OK)
{
con = file.read();
conitem = conpeek(con,1);
if(conItem!="0")
{
notepadTable.initValue();
notepadTable.Name=conpeek(con,1);
notepadTable.MathsMark=conpeek(con,2);
notepadTable.PhysicalMark=conpeek(con,3);
notepadTable.insert();
}
 
 
 
}
ttscommit;
         

No comments:

Post a Comment