Monday, June 13, 2011

Reading CSV File in AX

Query:
How can I read a csv file in AX?

Answer:
use the following code,

public void run()
{
    #File
    CommaTextIo commaTextIo;
    FileIOPermission permission;
    container containFromRead;
    int x;
    int cols;
    PurchIdBase purchId;
    LineNum lineNum;
    ;
    super();
    if(!this.validate())
    {
        return;
    }


    try
    {
       
        permission = new FileIOPermission(filePath, #io_read);
        permission.assert();


        commaTextIo = new CommaTextIO(filePath, #io_read);
        containFromRead = commaTextIo.read();


        while(containFromRead)
        {
            cols = conLen(containFromRead);
            for(x=1; x <= cols; x++)
            {
                info(any2str(conpeek(containFromRead, x)));
            }
            containFromRead = commaTextIo.read();
        }
        commaTextIo = null;
    }
    catch(Exception::Error)
    {


    }
}

3 comments:

  1. Microsoft Dynamics AX training, do keep a few things in mind to get the maximum out of the course as well as the application.we teach Microsoft Dynamics AX training and class at Hyderabad.Microsoft Dynamics CRM training in Hyderabad, Microsoft Dynamics NAV training in Hyderabad

    ReplyDelete
  2. Microsoft Dynamics CRM training will help you manage and prioritize your business goals, customize.we teach MS Dynamics CRM training and class available at Hyderabad.Microsoft Dynamics AX training in Hyderabad, Microsoft Dynamics NAV training in Hyderabad

    ReplyDelete
  3. Microsoft Dynamics NAV training could be a lifelong asset for your role in a small or medium enterprise.NAV Technical, NAV Trade, NAV Finance.we teach Microsoft Dynamics NAV training and class available at Hyderabad Microsoft Dynamics AX training in Hyderabad, Microsoft Dynamics CRM training in Hyderabad

    ReplyDelete