How to read from csv file in Dynamics AX 2012 Through X++
How to read from csv file in Dynamics AX 2012 Through X++
static void readFromCSV(Args _args)
{
#File
CommaTextIO csvFile;
container readCon;
Dialog dialog;
DialogField dfFileName;
FileName fileName;
int row;
CustAccount custAccount;
ItemId itemId;
Qty qty;
dialog = new Dialog("Read data from csv file");
dfFileName = dialog.addField(extendedTypeStr("FilenameOpen"));
dialog.filenameLookupFilter(['csv','*.csv']);
if (dialog.run())
{
csvFile = new CommaTextIo(dfFileName.value(), 'r');
csvFile.inFieldDelimiter(',');
readCon = csvFile.read();
ttsBegin;
while(csvFile.status() == IO_Status::OK)
{
readCon = csvFile.read();
if(readCon)
{
custAccount = conPeek(readCon,1);
itemId = conPeek(readCon,2);
qty = conPeek(readCon,3);
info(strFmt('%1 %2 %3',custAccount,itemId,qty));
}
}
ttsCommit;
}
}
Comments
Post a Comment