Interview Questions

Thursday, October 22, 2015

Create CSV file through code in AX 2012 R3

static void Gulshan_TestCSV(Args _args)
{
CommaTextIo file; 
String30    CTN;
container line;
CustTable custTable;
#define.filename(@'C:\Test\ABC.csv')
#File
file = new CommaTextIo(#filename, #io_write);
if (!file || file.status() != IO_Status::Ok)
{
throw error("File cannot be opened.");
}
CTN = custTable.name();

while select AccountNum from custTable
{
line = [
custTable.Name() ,
custTable.Name()];
file.writeExp(line);
}
info(strFmt("File %1 created in specified folder.", #filename));
}

No comments:

Post a Comment