Dynamics AX Data Migration: Importing Numerical Values from Text Files

Dynamics AX Data Migration: Importing Numerical Values from Text Files

During data migration you may have to import data from legacy systems that output data in a text or CSV file. This data may need special formatting so that the data can be properly read by Dynamics AX. This is especially true when importing numerical values from a text file. For Example, the value ’34,203.00’ in the text file may be incorrectly read as the value 34 in Dynamics AX if the data is not properly converted from a text value to a numerical value because of the comma in the value. It is possible to strip out commas so the data can be properly converted, however it’s also possible to use modern .net code design patterns to convert the data.

Properly Converting to a Numerical Value in Dynamics AX

Converting a numerical value in a text or CSV file may not be properly converted to a numerical value in AX. For example, during data migration, if you import customer data with a credit limit value then this may not be properly converted to a number. Figure 1 shows sample code that simulates a value of “25,239.78”. If this text value contains a comma, it may not be converted properly to a number.

static void AXMTestStr2Num(Args _args)
{
str inputStr = "25,239.20";
real realConversion;
;
realConversion = str2num(inputStr);
}

Figure 1. Sample code conversion from a text file.

If we use standard conversion code in AX to convert a string value to a number, we can see this truncating the number. See Figure 2.

Figure 2. Text value not properly converted to a number

Figure 2. Text value not properly converted to a number

Figure 3 and Figure 4 shows .net code that can be called from Dynamics AX to convert the string value to a number.

static void AXMTestStr2Num2(Args _args)
{
str inputStr = "25,239.20";
real realConversion;
;
System.Decimal::TryParse(
inputStr,
System.Globalization.NumberStyles::Number,
System.Globalization.CultureInfo::CreateSpecificCulture(infolog.language()),
byRef realConversion);

}

Figure 3: Sample code & .net formatting

Figure 4: .net conversion results

Figure 4: .net conversion results

This approach can be extended to convert string values to other AX data types, including Dynamics AX Date and date/Time fields.

Reading in data from text files to Dynamics AX can lead to issues when converting text values to non-text values, such as numerical values, or date/time values. This code snippet shows how text values containing commas can be converted to numerical values.

About Michael Oakes

Michael Oakes has created 3 entries.

Post A Comment

YOUR CAPTCHA HERE

Contact Us

All fields required

First name

Last name

Company

Your Email

Subject

Your Message

×

Meet Us

All fields required

First name

Last name

Company

Your Email

Available Date & Time
AMPM

Your Message

×

Subscribe to our mailing list

* indicates required
 

×
Learn More

Contact Us

All fields required

First name

Last name

Company

Your Email

Subject

Your Message

×

CRM Test Form

×

Influence

All fields required

First name

Last name

Company

Your Email

Proposed Webinar Date & Time
AMPM

Your Message

×

Contact Us

All fields required
×

Contact Us Here! 

* indicates required

×

We want to hear your feedback

∗ indicates required

×

Let us keep you updated!

 ∗ indicates required

×

Meet Us

All fields required

First name

Last name

Company

Your Email

Available Date & Time
AMPM

Your Message

×

Contact Us Here! 

* indicates required

×

Contact Us Here! 

* indicates required

×

Schedule your meeting with us!

* indicates required

×

Schedule your meeting with us!

* indicates required

×

Book Your Time

×

                        RAMPUP SUBSCRIPTION PLANS

                    Choose a plan below, and one of our

              Support Consultants will contact you shortly.

×

                           PACKAGES START AT $4,999

                  Choose a package below, and one of our 

               Support Consultants will contact you shortly.

×

 Performance Review Details

 

Diagnostic Review of DyanmicsAX Server (AOS) & SQL performance and stability.

 

Written summary of findings and recommendations.

 

Up to 15 hours of issue resolution time to target your most immediate performance issues.

 

Review completed by our 100% onshore support team averaging more than 10+ years of DynamicsAX experience.

 

Get the help you need now, with no long-term commitment.

×

Functional/Department Help Pick 3

 

Help with up to 3 functional or department issues such as: invoicing, costing, closing the books, AR, AP, inventory, warehousing, etc.

 

Talk with our 100% onshore functional experts with over 250+ years of combined AX experience to define your issues and find recommended solutions.

 

Up to 20 additional hours of issue resolution time included.

 

Presentation of solutions and next steps from our expert team.

 

Get the help you need now, with no long-term commitment.

 

×

Reporting / BI Help

 

Choose up to 3 standard or custom reports for assistance.

 

Solve typical issues like: Report too slow, does not show what we need, need an additional field/column, etc.

 

Talk with our 100% onshore functional experts with over 250+ years of combined AX experience to troubleshoot report issues and recommend solutions.

 

Up to 20 additional hours of configuration or development time included.

 

Presentation of solutions and next steps from our expert team.

 

Get the help you need now, with no long-term commitment.

×

Please fill in the form to RSVP

 

×