Calling CSV file through X++ in ax 2012

#File
#aviFiles

FileIOPermission permission;
container readCon, _returnstatus, _dimensionColumnValue, _dimensionColumnName;
int cnt, numLines;
TextIO textIO;
textBuffer tb = new textBuffer();
CommaIo csvFile;
str _branch, _division, _cc, _equipment, _empl, _lc, _custVendID;

RecId _productID;
str _catCode;

int _counter;

;

permission = new fileIOpermission(_fileName,#io_read);
permission.assert();

textIO = new TextIO(_fileName,#io_read);
if (!textIO)
{
throw error(“Error reading provided CSV file”);
}

tb.fromFile(_fileName);//File name with Path …
numLines = tb.numLines();
csvFile = new CommaIo(_fileName, ‘r’);
csvFile.inFieldDelimiter(” “); // Delimiter…

if (csvFile)//Checking for csv file.
{
readCon = csvFile.read();//reading the file.
for(cnt=1;cnt<=numLines;cnt++)
{
readCon = str2Con(tb.nextToken(true));
if(cnt>1)
{
ttsBegin;

ttscommit;

}

}

}

Advertisements

One comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s