Wednesday 21 December 2011

How export data to csv file in Ax 2009

Hi friends ,

   Today we will learn the exporting of data from Ax 2009 to csv file format. The programming is done through X++ code. Change the code as per your requirements. Now we will have a simple example of writing the invent table to the csv file

public static void main(Args _args)
{
    Commaio file;
    container line;
    InventTable inventTable;
    #define.filename("C:\\Items.csv")
    #File

    ;
    file = new Commaio(#filename , #io_write); or  file = new Commaio(#filename , 'W');
    //file.outFieldDelimiter(';');
    if( !file || file.status() != IO_Status::Ok)
    {
        throw error("File Cannot be opened");
    }
    while select inventTable
    {
        line = [inventTable.ItemId,inventTable.ItemName];
        file.writeExp(line);

    }


}
  As per this you can save the document in any format such as doc,txt,xls only.
warning this is not used in xml
                                                        Vivek Chirumamilla

No comments:

Post a Comment