Wednesday 21 December 2011

How to import data from a csv file to Ax 2009

Hi friends,

 Today we have a small requirement of importing data into Ax 2009 from a csv file. We imported a small data to the InventTable.
Note:: The follwing does not followed the best practices please bear that in mind

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

    ;
    file = new Commaio(#filename , 'R');
    file.inFieldDelimiter(',');
    if( !file || file.status() != IO_Status::Ok)
    {
        throw error("File Cannot be opened");
    }
 
         line = file.read();
         inventTable.ItemId = conpeek(line,1);
        inventTable.ItemName = conpeek(line,2);
        inventTable.insert();
}
Please made changes as per your requirement.
                                                                    Vivek Chirumamilla

No comments:

Post a Comment