Translate

Sunday, February 24, 2013

Read/Write data using Excel

static void Write2ExcelFile(Args _args)
    InventTable             inventTable;
    SysExcelApplication     application; 
    SysExcelWorkbooks       workbooks;
    SysExcelWorkbook        workbook;
    SysExcelWorksheets      worksheets;
    SysExcelWorksheet       worksheet;
    SysExcelCells           cells;
    SysExcelCell            cell;
    int                     row;
    ;

    application         = SysExcelApplication::construct();
    workbooks           = application.workbooks();
    workbook            = workbooks.add();
    worksheets          = workbook.worksheets();
    worksheet           = worksheets.itemFromNum(1);
    cells               = worksheet.cells();
    cells.range('A:A').numberFormat('@');

    cell                = cells.item(1,1);
    cell.value("Item");
    cell                = cells.item(1,2);
    cell.value("Name");
    row                 = 1;
    
    while select inventTable
    {
        row++;
        cell = cells.item(row, 1);
        cell.value(inventTable.ItemId);
        cell = cells.item(row, 2);
        cell.value(inventTable.ItemName);
    }
    
    application.visible(true);
}

Reading Data from Excel File

static void ReadExcel(Args _args)
    SysExcelApplication     application;
    SysExcelWorkbooks       workbooks;
    SysExcelWorkbook        workbook;
    SysExcelWorksheets      worksheets;
    SysExcelWorksheet       worksheet;
    SysExcelCells           cells;
    COMVariantType          type;
    int                     row;
    ItemId                  itemid;
    Name                    name;
    FileName                filename;

    ;

    application             = SysExcelApplication::construct();
    workbooks               = application.workbooks();
    //specify the file path that you want to read
    filename                = "C:\\item.xls";
    try
    {
        workbooks.open(filename);
    }
    catch (Exception::Error)
    {
        throw error("File cannot be opened.");
    }

    workbook        = workbooks.item(1);
    worksheets      = workbook.worksheets();
    worksheet       = worksheets.itemFromNum(1);
    cells           = worksheet.cells();
    
    do
    {
        row++;
        itemId = cells.item(row, 1).value().bStr();
        name = cells.item(row, 2).value().bStr();
        info(strfmt('%1 - %2', itemId, name));
        type = cells.item(row+1, 1).value().variantType();
    }
    while (type != COMVariantType::VT_EMPTY);
        application.quit();
}

Sunday, February 17, 2013

AIF run manually using job

static void processAIF(Args _args)
{
    ;
    // read the messages
    new AifGateWayReceiveService().run();

    // process the messages in queue
    new AifInboundProcessingService().run();

    // process messages in queue
    new AifOutboundProcessingService().run();

    // send messages
    new AifGateWaySendService().run();
}

Wednesday, February 13, 2013

101 Dynamics AX Interview Questions





101 Microsoft Dynamics AX Interview Questions





Mukesh Hirwani
Follow me @

Download your copy from here: