Quantcast
Channel: Microsoft Dynamics AX Forum - Recent Threads
Viewing all articles
Browse latest Browse all 175888

RE: Are Memo fields (nvarchar(max)) supported in DMF?

$
0
0

I also had a problem with memo fields. I’m importing data from AX3.0 to AX2012 R3 using ODBC. Same situation as you wrote Taylor, when I try to import data to staging tables, DIXF service crashes.

I have workaround, maybe not much elegant ;-) but it works for me.

Let’s say, I want to import AssetTable and have a problem with field MaintenanceInfo3 which is a memo field.

Step 1 First I have to check the maximum length of data in this field in source table. I use SQL query:

SELECT MAX(DATALENGTH(MAINTENANCEINFO3)) FROM ASSETTABLE

SQL type of my base field is Text so I use datalength() function. Use len() for nvarchar types.

Step 2 Every memo field in staging tables that is used in mappings is a “crash generator” so it should be changed to fixed size string. I’m changing every existing memo to string 1000 and duplicating this field as much times as is needed to get all data from source table. In my example max length of data is 1773 so I need two fields MaintenanceInfo3 and MaintenanceInfo3_2 to get all the data..

Step 3 I need to prepare data to fill these new fields in staging. I use sql statement

SELECT (…)

SUBSTRING(ASSETTABLE.MAINTENANCEINFO3, 1, 1000) AS MAINTENANCEINFO3,

SUBSTRING(ASSETTABLE.MAINTENANCEINFO3, 1001, 1000) AS MAINTENANCEINFO3_2

(…) FROM ASSETTABLE

Step 4 Then I use ‘Generate source mapping’ button to update mappings to stage. If field names in staging table and select statement are equal, mapping is added automatically.

Step 5 Now I can click ‘Get staging data’. The process should end without crash.

But this is half the battle ;-)

Step 6 Now I should get all those fields together and put into target memo field. To do this, I write generate* method in *EntityClass. In my example it looks like this:

[DMFTargetTransformationAttribute(true),DMFTargetTransformationDescAttribute("Function that generates MaintenanceInfo3"),

DMFTargetTransformationSequenceAttribute(10),

DMFTargetTransFieldListAttribute([fieldStr(DMFAssetEntity,MaintenanceInfo3), fieldStr(DMFAssetEntity,MaintenanceInfo3_2)])]

public container generateMaintenanceInfo3(boolean _stagingToTarget = true)

{

   AssetMaintenanceInfoMemo maintenanceInfo3;

   if (_stagingToTarget)

   {

       maintenanceInfo3 = entity.MaintenanceInfo3;

       if (entity.MaintenanceInfo3_2)

           maintenanceInfo3 += entity.MaintenanceInfo3_2;

   }

   else

   {

       maintenanceInfo3 = target.MaintenanceInfo3;

   }

   return [maintenanceInfo3];

}

I also need to modify method getReturnFields() by adding new case

       case methodStr(DMFAssetEntityClass, generateMaintenanceInfo3) :

           con += [fieldstrToTargetXML(fieldStr(AssetTable, MaintenanceInfo3))];

           break;

Step 7 Now I can recreate target mappings. I go to ‘Target entities’ form, click ‘Modify target mapping’, then ‘Mapping details’ and ‘Generate mapping’. New mapping based on method from previous step should be added.

Step 8 Get back to processing groups and do “Copy data to target’ action. New records should be created, memo fields should be filled now.

In very similar way I have managed with array fields (generate* method is a little bit different).

If anyone have easier way to resolve this issue, please let us know :)


Viewing all articles
Browse latest Browse all 175888

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>