Quantcast
Channel: Dynamics AX 2012 Data Import using DMF
Viewing all articles
Browse latest Browse all 13

Microsoft Dynamics AX 2012 DMF - Table Primer

$
0
0
Microsoft Dynamics AX 2012 DMF – Table Primer
 
Purpose: The purpose of this document is to illustrate how to use Dynamics AX 2012 DMF for import of custom data. In this particular primer I’ll be focusing on Entity type = Table.
 
Challenge: Data model changes in Dynamics AX related to high normalization and introduction of surrogate keys made import of data more complex. Data Migration Framework for Microsoft Dynamics AX 2012 was designed and developed to address this challenge. Data Migration Framework for Microsoft Dynamics AX 2012 provides architectural foundation for data import process as well as it ships with the numerous standard templates covering most important types of business data.
 
Solution: Dynamics AX 2012 ships with the number of DMF templates which can be used in data import scenarios. However for import of custom data you can also use appropriate tables. A table entity enables you to migrate data from a source to a target Microsoft Dynamics AX table directly, without going through a staging table or applying any business logic. Unlike other entities, data cannot be pushed from one source table to multiple target tables. The direct table entity must be a one-to-one mapping from source to target.
 
Data Model:
 
Table Name
Table Description
AlexParent
Sample table
AlexTable
Sample header table which extends from sample table
AlexLine
Sample lines table
 
Data Model Diagram:
 
Sample Data Model
 
<![if !vml]><![endif]>
 
Process Overview:
 
<![if !vml]><![endif]>
 
Walkthrough:
 
Project1
 
Please note that I initially created 3 tables to implement a data model for this scenario
 
AlexParent
 
 
AlexTable
 
 
AlexLine
 
 
Target entities
 
 
Processing group: Alex
 
 
Select entities for processing group: Alex
 
 
CSV File: AlexTable
 
This is how the source file looks like for AlexTable
Screenshot
Text
ID,FieldC,FieldD
1,C1,D1
Please note that the first row is header row, after that we have business data in CSV format
 
CSV File: AlexLine
 
This is how the source file looks like for AlexLine
Screenshot
Text
ID,FieldE,FieldF
1,E1,F1
Please note that the first row is header row, after that we have business data in CSV format
 
Generate source mapping: AlexTable
 
Please note that there's no need to create mapping manually, this mapping is already pre-created for you.
 
Generate source mapping: AlexLine
 
Please note the warning because AlexTable field (RecID reference to AlexTable table) couldn’t be automatically mapped
 
Table: AlexLine
 
Remark: Added Replacement key (ID) to AlexLine table in order to be able to do ID -> RecId (AlexTable) translation via script
 
Generate source mapping: AlexLine
 
Please note that now the system was able to automatically map fields.
 
Select entities for processing group: AlexTable
 
Once file is specified you can preview the data by pressing "View source data" button, then the data will be displayed in Preview pane.
 
Map source to target – Mapping details: AlexTable
 
 
Map source to target – Mapping visualization: AlexTable
 
 
Select entities for processing group: AlexLine
 
Once file is specified you can preview the data by pressing "View source data" button, then the data will be displayed in Preview pane.
 
Map source to target – Mapping details: AlexLine
 
 
Map source to target – Mapping visualization: AlexLine
 
Please note that DMF imports the data into tables using SSIS package and you don’t have a benefit of AX kernel taking care of properly inserting records into appropriate tables according to Table inheritance, that’s why I had to make a data model change to remove Table inheritance from AlexTable table
 
AlexTable: Correction to the data model to remove Table inheritance
 
Please also note that changes were made in R2 to the way Table inheritance is physically organized on SQL level, starting from R2 release the only one table will be created on SQL side with all required fields. When insert occurs to the table with Table inheritance the system will create records populating only required fields.
 
Execute source to staging: After you execute source to staging data import the system will confirm how many records were synchronized with target table
 
 
Execution history: The results and time consumed can be seen in Execution history form
 
 
Result:
 
Dynamics AX – Table Browser
 
AlexTable
 
 
AlexLine
 
Remark: Please note that I can’t use functions with Tables, that’s why initially AlexTable field on AlexLine record is blank (0). At the same time I introduced ID field which I can populate without any problems. So now in order to populate AlexTable (RecID reference to AlexTable record) on AlexLine record I’ll have to execute additional step – run X++ job.
 
Job: AlexTableTestJob
 
 
Job: AlexTableTestJob – Source code
 
staticvoid AlexTableTestJob(Args _args)
{
    AlexTable   AlexTable;
    AlexLine    AlexLine;
 
    ttsBegin;
 
    whileselectforupdate AlexLine
        join AlexTable
            where AlexLine.ID == AlexTable.ID
    {
        AlexLine.AlexTable = AlexTable.RecId;
        AlexLine.update();
    }
 
    ttsCommit;
}
 
AlexLine
Remark: Once I executed X++ job AlexTable field (RecID reference to AlexTable record) is properly populated now
 
Now I can remove ID field from AlexLine table
 
AlexLine: Correction to the data model to remove ID field
 
 
AlexLine
 
Remark: As the result AlexLine table contents will look like this
 
Versions: Microsoft Dynamics AX 2012 R2, Microsoft Dynamics AX 2012 Data Migration Framework v2.0
 
Summary: In this document I explained how to use Data Migration Framework in Microsoft Dynamics AX 2012 in order to import custom data using Tables. This approach is especially recommended for large scale data migrations and allows for much better performance comparing to usage of Microsoft Dynamics AX 2012 Excel Add-in. Data Migration Framework in Microsoft Dynamics AX 2012 already ships with numerous standard templates for most important types of business data. Please note that v2.0 release has support for 26 business entities. Data migration is iterative process and the fact that DMF provides flexible validation capabilities facilitates this process significantly.
 
Author: Alex Anikiiev, PhD, MCP
 
Tags: Dynamics ERP, Dynamics AX 2012, DMF, Data Migration Framework, Data Import, Data Conversion, Data Migration, Table, Table Inheritance
 
Note: This document is intended for information purposes only, presented as it is with no warranties from the author. This document may be updated with more content to better outline the concepts and describe the examples.
 

Viewing all articles
Browse latest Browse all 13

Trending Articles