Create csv file in axapta


 CommaIo file;  
 container line;  
 LedgerTable ledgerTable;  
 #define.filename('\\accounts.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);  
 }