axapta code for csv transaction, Axpata to CSV, Code to create csv file from table data in axapta, Code to create csv file from table data using x++ code, CommaTextIo, Data to .xls file

If you want  Code to create csv file from table data using x++ code in Axapta application

Try this code in job 

//Declaration of variables
#File
CommaTextIo commaTextIo;
FileIOPermission permission;
CustTable custTable;
//assign file path and file name
str fileName = strFmt('%1\\ax_%2.csv', WinAPI::getTempPath(), "Name"); // @"C:\My Documents\abc.csv";
;

permission = new FileIOPermission(fileName,#io_write);
permission.assert();
commaTextIo = new CommaTextIo(fileName,#io_write);

//select data in query to write in csv file
while select custTable
{
    commaTextIo.write(custTable.AccountNum,custTable.Name);

}

CodeAccessPermission::revertAssert();

//After execution of job you can see .csv file in temp folder

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.