Microsoft Dynamics Ax 2012 FP/R2 - Invent - Item Posting Issue & Workaround

Issue: Ax 2012 (FP CU1 & Above) - Item Posting Profile Issue using .DAT and .DEF File - While importing Item Posting data from one instance to other instance - Solution for this issue is as below.

Issue Description:

  • The Item Posting is done in AX 2012 to tag the items or the item groups with the Main Accounts.
  • A rec id is generated at the time of posting. Master company is created with the respective set-ups.
  • The Master Company data is migrated to the New Legal entity using the AX Import/export feature.
  • Due to Rec id not being refreshed while creating Purchase orders related to item posting after migration of data transactions were not being posted to the respective posting profile Main accounts.


  • Usually the item posting profile in the created Legal Entity is deleted and created again with the same values(Main accounts, Item groups) so that a new Rec Id is generated and then the Purchase order cycle is run. This activity becomes time consuming.
  • In order to save time also considering data accuracy with accurate tagging of Main Accounts, related transactions a New/Custom entity is developed in Data Export/Import Framework.
  • All the mandatory fields are included in the template and the data is validated in the staging process itself before copying it to the target i.e. the Legal Entity.
  • After mapping and successful validation in staging, the data required for Item Posting is migrated.

What is Data Migration Framework / Data Export Import Framework:

  • The Microsoft Dynamics AX 2012 Data Import/Export Framework is an extension that helps you export data and import it into Microsoft Dynamics AX. Examples of the data that you can import include master data, open stock, and balances.

    For More Info –

Steps to Create/Customize Custom Entity in Data Migration Framework / Data Export Import Framework:

Navigation Path for creating custom entity by using the Wizard:

Main Menu->Data migration Framework->Common->Create a custom entity for migration

Click next.

Select the table “InventPosting” in the Table Name.

Click next and Finish button.

A Project is created automatically in the private project after compilation:

Entity Table Name: DMFInventPostingEntity

Entity query name: DMFInventPostingTargetEntity

Entity class name: DMFInventPostingEntityClass

Create a Target Entity → Set-Up->Target entities->New

After the Target entity is created, the data can be imported using the Data Migration framework.

Check the Modify target mapping for field mappings visualization:

Generate a template for importing the data:

Note: the fields except “LedgerDimension” others are ENum’s hence to map exact values to be imported, Use the Values of Enums for Importing the data.

Common steps to create a custom entity manually:
Create an enum field in the target entity
The enum field in the target entity is represented by a string field in the staging table. A new extended data type (EDT) of type string, and of appropriate length to take the enum label strings has to be created.
The conversion between the enum (Target) and string (Staging) is handled automatically by the Data Import/Export Framework.
A staging table usually has natural keys (strings). If the target table contains fields that are RecIds from other tables, the natural key must be converted to a RecId.
In this case, there are two options:

  • Add a data source so that the referenced table can be added to the target entity query.
  • Create a function
  • Add a data source
  • Add a data source so that the referenced table can be added to the target entity query.
    In many scenarios, if the name of the field in the target query is same as the staging field, the mapping is performed automatically.
    Create a function
  • Create a function on the entity class.
  • The related fields for the RefRecId on the staging table should be natural keys from the staging table.
  • Create a method on the entity class to convert the string to a RecId.
    When a function is approached, a field group must be created for the staging table, and the return fields on the target must be specified in the getReturnFields method in the entity class**.**

1. DMF Class & Interface Descriptions

1.1.1. DMFInventPostingEntityClass



It declares the object for the staging table (DMFInventPostingEntity) with the name entity.

Declares the object for the main table for the target entity (InventPosting)with the name target.


It takes the staging table as parameter i.e. DMFInventPostingEntity.The value entity is initialized from the parameter.Initialisation takes place in this method.

It takes the staging table as parameter i.e. DMFInventPostingEntity.It creates and returns the object of the DMFInventPostingEntityClass class by using the parameter.

The parameter used here is _common and _dataSourceName. The parameter represents the datasources that are present in the target entity query. If the tableId of the source maps with the table number of the target entity then the source data will be mapped to the target entity.


The getReturnFields method is used to specify the default output or target fields for the functions that are used for data migration. This method is created for either wizard-based or manual projects.

Parameters include:

_entity: entity name

_name: method name

Return: must return a container, as well as the name of the data source in the target entity query with which the method should be executed, and the name of the data source field in the target entity query which should be initialized by executing the Function

Return Value:- container


Defined Parameters in this Method :

boolean _stagingToTarget = true: true if the update succeeded; otherwise, false

This method uses If Else statement. It also maps the fields in staging table to target table.
The container is declared as “res”.
If the fields are mapped properly in staging to target entity, the data will be imported.
Conpeek function converts the peeked item into expected datatype.
If the staging to target parameter is true which is default value, then based on the ledger dimension and company, the dimension will be generated.
Else the existing ledger dimension of the target will be inserted in the container.