Export data to text file.

I am exporting the data to text file from AX.

But the issue is when it exports the data the data comes with double quotation “ASSETS”. I want to data to be exported with out the quotes.

Is there any way i can do like this.

Thanks.

Please Elaborate More…and How do you Export data to Text ?

Good Luck

public static client void main(Args _args)
{
CommaIo file;
container line;
LedgerTable ledgerTable;
#define.filename(‘c:\accounts2.csv’)
#File
;

file = new CommaIo(#filename, #io_write);

if (!file || file.status() != IO_Status::Ok)
{
throw error(“File cannot be opened.”);
}
while select ledgerTable
{
line = [
ledgerTable.AccountNum,
ledgerTable.AccountName];
file.writeExp(line);
}
}

Instead of CommaIO make use of TextIO

public static client void textFileExporting(Args _args)

{

TextIO file;

container line;

LedgerTable ledgerTable;

#define.filename(‘c:\accounts.csv’)

#File

;

file = new TextIO(#filename, #io_write);

file.outFieldDelimiter(’;’);// for semicolon seperator

if (!file || file.status() != IO_Status::Ok)

{

throw error(“File cannot be opened.”);

}

while select ledgerTable

{

line = [ledgerTable.AccountNum,ledgerTable.AccountName];

file.writeExp(line);

}

}

Thanks kranthi it worked !

Thanks. It works for me

Hi Kranthi

I am exporting a csv file in batch process and i am getting the following error

System.NullReferenceException: Object reference not set to an instance of an object.

I am getting the error at below point of code

textIo =

new TextIo(path, #io_write, 0);

commaTextIo.outFieldDelimiter(";");

But when i run manually i dont get any error. The problem is coming only if i run through batch process.

And also i have several files (1000’s) that get generated and in batch the error is coming after some files are already generated. For eg only around 500 are generated but if i run manually there are around 2000

This is my code

permission =

new FileIOPermission(path, #io_write);

permission.assert();

textIo =

new TextIo(path, #io_write, 0);

textIo .outFieldDelimiter(";");

CodeAccessPermission::revertAssert();

textIo .write();

I have tried so many ways to give the permissions…

Do you have any idea what might be causing the problem ?

Thanks in Advance