Writing data to a Text FileThe below code is to write data from AX 2012 table to text file
static void WriteToTextFile(Args _args)
{
TextIO file;
Filename filename = @"C:\TEMP\customers.txt";
CustTable custTable;
container con;
FileIOPermission permission;
#File
try
{
//permission = new FileIOPermission(filename, #io_write);
//permission.assert();
file = new TextIo(filename, #io_write);
if(file == null)
throw Exception::Error;
file.outRecordDelimiter(#delimiterCRLF);
file.outFieldDelimiter(";");
while select custTable
{
con = conNull();
con = conIns(con,1,custTable.AccountNum);
con = conIns(con,2,custTable.name());
con = conIns(con,3,custTable.InvoiceAccount);
con = conIns(con,4,custTable.CustGroup);
file.writeExp(con);
}
}
catch(exception::Error)
{
error("Can not access to write the file");
}
//CodeAccessPermission::revertAssert();
}
No comments:
Post a Comment