Saturday, February 15, 2014

How To Read Csv file in Ax 2012

//To Read Csv  file in Ax 2012

How to read CSV file in AX
    #file
    CommaTextIo       commaTextIo;      
    fileiopermission     permission;
    container              c;
    int                        x;
    int                        cols;

    permission = new fileiopermission('c:\\test.csv',#io_read);
    permission.assert();

    // specify the source file name ie. "test.csv"
    commaTextIo = new CommaTextIo('c:\\test.csv','r');
    c = commaTextIo.read();

    while(c)
    {
        cols = conlen(c);
        for(x = 1; x <= cols; x++)
        {
              info (any2str(conpeek(c,x)));
        }
        c = commaTextIo.read();
   }

   commaTextIo = null;

No comments:

Post a Comment

Copy Markup charges while posting purchase invoice using X++

 Copy Markup charges while posting purchase invoice using X++ Class: Important: Code logic is just for Reference.  New class => Duplicate...