How to create csv file in Dynamics AX 2012 Through X++
#File
CommaTextIo commaTextIo_File;
container file_Line;
CustTable custTable;
FileIoPermission permission;
Filename fileName = @"C:\\Temp\\FileName.csv";
permission = new FileIoPermission(fileName, #io_write);
permission.assert();
commaTextIo_File = new CommaTextIo(fileName, #io_write);
if (!commaTextIo_File || commaTextIo_File.status() != IO_Status::Ok)
{
throw error("Error when try create file.");
}
commaTextIo_File.outRecordDelimiter('\r\n');
commaTextIo_File.outFieldDelimiter(',');
while select firstonly10 CustTable
{
file_Line = [CustTable.AccountNum,CustTable.name()];
commaTextIo_File.writeExp(file_Line);
}
CodeAccessPermission::revertAssert();
info(strFmt("File created in the following path: %1.", filename));
CommaTextIo commaTextIo_File;
container file_Line;
CustTable custTable;
FileIoPermission permission;
Filename fileName = @"C:\\Temp\\FileName.csv";
permission = new FileIoPermission(fileName, #io_write);
permission.assert();
commaTextIo_File = new CommaTextIo(fileName, #io_write);
if (!commaTextIo_File || commaTextIo_File.status() != IO_Status::Ok)
{
throw error("Error when try create file.");
}
commaTextIo_File.outRecordDelimiter('\r\n');
commaTextIo_File.outFieldDelimiter(',');
while select firstonly10 CustTable
{
file_Line = [CustTable.AccountNum,CustTable.name()];
commaTextIo_File.writeExp(file_Line);
}
CodeAccessPermission::revertAssert();
info(strFmt("File created in the following path: %1.", filename));
Comments
Post a Comment