July 17, 2012

How export data to csv file in Ax 2009

How export data to csv file in Ax 2009

Hi friends ,

   Today we will learn how to exporting our  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:\\dpk_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);
    }
}

You can save the document in any format such as doc,txt,xls only.


-Harry

Simple Dialog Box in Ax 2009

Simple Dialog Box Example in Ax 2009


Hi Friends ,
Today we are tring to develop a  simple DialogBox .
try to following code


static void Simple_Dialog(Args _args)
{
dialog dlg;
dialogGroup dlgGroup;
dialogField dlgField;
;
dlg = new dialog("Simple Dialog");
dlgGroup = dlg.addGroup("Customer");
dlgField = dlg.addField(TypeID(custAccount),"Account
Number");
if (dlg.run())
{
print dlgField.value();
pause;
}
}


-Harry