Search This Blog

Monday 27 January 2014

X++ code to Import Excel Data to Ax Tables

static void ReadExcel(Args _args)
{
    SysExcelApplication application;
    SysExcelWorkbooks   workbooks;
    SysExcelWorkbook    workbook;
    SysExcelWorksheets  worksheets;
    SysExcelWorksheet   worksheet;
    SysExcelCells       cells;
    COMVariantType      type;
    int                 row;

    CustAccount         custAccount;
   
    Name                name;
    FileName            filename;
    CustNew             custNew;
    ;

    application = SysExcelApplication::construct();
    workbooks = application.workbooks();
   
    filename = "F:\\Copy of CustTable.xls";
  custNew.clear(); 
   


   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++;
        custAccount = cells.item(row, 1).value().bStr();
        name = cells.item(row, 2).value().bStr();
        type = cells.item(row+1, 1).value().variantType();

        custNew.AccountNum=custAccount;
        custNew.Name=name;
        custNew.insert();

    } while (type != COMVariantType::VT_EMPTY);
    application.quit();
}


Monday 20 January 2014

Difference Between AX 2004 , AX 2009 and AX 2012

S.No AX 4.0 AX 5.0 AX 2012
1 The setup program installs deployment files, such as the Application Object Data (AOD) and Application Label Data (ALD) files on a file share. The setup program installs deployment files, such as the Application Object Data (AOD) and Application Label Data (ALD) files on a file share. The AOD & ALD files are now stored in the model store and alternateModel Store. Model store is stored in the SQL database.
Models can be exported, installed, or uninstalled from the model store. Models are identified by a name and a publisher, and have a set of properties that can be changed, including a version number.
2 .aod is the extension for application files .aod is the extension for application files .axmodel is the extension for Model
3 Management of AOD: Management of AOD Management of Models:1. AXUtil.exe command-line utility is used to create, export, import, uninstall, and list installed models.
2. Programmatically: Developers can use the DLL(axutilib.dll) to create custom interfaces to manage models.
3. PowerShell cmdlets used to create scripts to perform actions repeatedly along with create,export etc.i ll Explain how to create this things by next post…
4 AOD Files are used for storing the elements. AOD Files are used for storing the elements. AOD files are no longer used and are replaced by the model store. So AOD files from earlier versions are loaded into the new model store.
5 Workspace: The application workspace and development workspace are combined Workspace: The application workspace and development workspace are combined Workspace: The application workspace and development workspace are separated. The developer workspace contains all the tools and features a developer needs for creating and customizing an application. Saved changes in the Development Workspace are always synchronized with the Application Workspace within the same client instance.
6 Normal X++ Editor Normal X++ Editor X++ Editor based on hosting a Visual Studio 2010 Editor Framework control.
7 Normal X++ classes and methods are used for development Normal X++ classes and methods are used for development X++ classes and methods can now be draped with metadata in the form of attribute classes. An attribute class is any non-abstract class that inherits from the SysAttribute class. Detailed metadata is assigned through the constructor of the attribute class.
8 The system administrator had to manually copy label files from one environment to another. The system administrator had to manually copy label files from one environment to another. The label files are installed as part of the model file. Developers can view and import label (ALD) files in the Labels node in the AOT.
9 Reverse engineering is a feature that is used by partners to easily retrieve detailed information about the structures and relationships of the Microsoft Dynamics AX business logic and data model. Reverse engineering is a feature that is used by partners to easily retrieve detailed information about the structures and relationships of the Microsoft Dynamics AX business logic and data model. Reverse engineering tool is improved to support table inheritance and automatically includes parent elements in the generated models.
The Reverse Engineering tool lets you visualize data and object models generated from projects in Microsoft Dynamics AX. These models are created as Microsoft Visio documents
10 Able to define relations at EDT and Table levels. Able to define relations at EDT and Table levels. The ability to define relations on EDTs is removed
11 No Table Inheritance No Table Inheritance Table Inheritance: Just as an X++ class can inherit from another class, a table can inherit from another table. A table that inherits from the base table is called a derived table. the terms parent table and child table are used to describe foreign key relationships, not inheritance.
12 NoSurrogate Key NoSurrogate Key surrogate key is a system generated value that acts as the primary key of a table. This value is typically used instead of a set of fields called the natural key which would typically act as the primary key of a table. Microsoft Dynamics AX 2012 uses RecId as the surrogate key.
13 Temporary = Yes/No Temporary = Yes/No Temporary = Regular,InMemory,TempDb
The enum value TempDB is the new type of temporary table that is hosted in the underlying Microsoft SQL Server database. The enum value InMemory is the legacy type of temporary table that is hosted in the client.
14 NO No Full-text functionality that enables AX to search business data over a large volume of text data or documents. These can be automatically updated at the same time that the data is changed in the associated tables.
In the AOT, the Change Tracking property of a full-text index can be set to either Auto orManual. Indexes with the Auto property are updated automatically by the SQL Server as data is changed in associated tables. Indexes with the Manual property must be manually updated at a specified interval. The ChangeTracking property defaults to Auto for a new full-text index. Use the ChangeTracking property for optimum response time and throughput for the Microsoft Dynamics AX application.


15 16 byte object ID 16 byte object ID The 16 byte object ID is upgraded to 32 bytes. This change exponentially increases the number of object IDs.

Form Templates in AX 2012





Sunday 12 January 2014

Creating New PurchaseOrder Line after clicking a Button(AddLine)


Hi dude,

The Below code is used to create a Purchase order line & the created lines will be ready for posting .

This is one of my customization ...........

 
void clicked()
{
    Dialog      dialog;
    DialogField field;
    InventTable invTab
    InventSum   invSum;
    InventDim   invDim;
    PurchTable  purTab;
    PurchLine   purLine;
    int addPhyBal;
    ;
    dialog = new Dialog("Enter IteamGroup");
    field = dialog.addField(typeid(ItemGroupId));
    dialog.run();
    if (dialog.closedOk())
    {
     while select invTab join invSum
          where invTab.ItemGroupId==field.value() && invSum.ItemId==invTab.ItemId
          {
            addPhyBal+=invSum.AvailPhysical;
           
            if(addPhyBal<=1000)
             {
                select invDim where invDim.inventDimId == invSum.InventDimId;
                purLine.clear();
                purLine.PurchId=PurchTable.PurchId;
                purLine.ItemId= invSum.ItemId;
                purLine.InventDimId=invSum.InventDimId;
                invDim.inventBatchId = invDim.inventBatchId;
                invDim.InventColorId = invDim.InventColorId;
                invDim.InventLocationId = invDim.InventLocationId;
                invDim.inventSerialId = invDim.inventSerialId;
                invDim.InventSiteId = invDim.InventSiteId;
                invDim.InventSizeId = invDim.InventSizeId;
                invDim.configId = invDim.configId;
                purLine.PurchQty = 5000;
                purLine.createLine(true,true,true,true,true,true);// Create new PO lines
              }
            }
        PurchLine_ds.executeQuery();
     }
     super();
}

 

Friday 10 January 2014

X++ code to print the string in New Lines

Job:

static void TestStr(Args _args)
{
    TextBuffer t;
    ;
    t = new TextBuffer();
    t.setText("Hello.Welcome");
    while (t.nextToken(false,'.'))
    {
    info(t.token());
    }
}