As promised it is time to pick more things that I have improved for NAV 2016.  Still on the Data Exchange, and looking at file import.  We can import a text file; fixed and delimited, with different encoding.

By using Codeunit 1240 for the External Data Handling action we are able to get any text file into the Data Exchange framework.  It will simply prompt the user for a local file name.

Microsoft shipped Codeunit 1241 to read a flat file.  I decided to change that a bit with two enhancements.  First, I wanted to be able to read a delimited file and second, I wanted to be able to use different encoding.

The Codeunit name is “Fixed File Import” and just the name change show the difference.  My version is named “Fixed/Delimited File Import”.

There are settings in the Data Exchange that I wanted to be able to support.


The standard Codeunit only reads the MSDOS File Encoding with this code


to read the four different text encoding that are supported by the Data Exchange Setup.

The PharseLine section in the standard Codeunit has this simple loop to read the fixed file.

Extending this and adding two functions gives me the ability to import both fixed and variable text file.

More to come.  Stay tuned…


10 thoughts on “NAV 2016 Data Exchange – file import

  1. Rafal says:

    Have a look at the XMLport 1220 (Data Exch. Import – CSV) – it supports variable text length and all the different DataExchange Encodings

  2. Hi Gunnar

    I suppose this framework is not made with EDIFACT in mind, if my partners require that, the best bet is to still buy Anveo?

    1. Miklos, I have mapped EDIFACT as an XML file via the Data Exchange.

  3. paul says:

    I am wanting to use data exchange definitions for certain integrations of Sales Orders. There is a Generic Import type (used by PEPPOL invoice for example) but no Generic Export type. Should data exchange definition be able to export other things apart from Bank Statement and if so why is there no type available.

  4. Henrik Kronborg says:

    Any way to handle dimensions in the import.
    I need to import into the General Journal, and i have several shortcut dimensions that i have to import.

    1. Hi Henrik

      I would try to map to a buffer table and use the intermediate feature. Then in the mapping I would create the dimension set and use that.

  5. Marija says:

    Thank you very much!This is only blog I could found about Data Exchange Definitions…Any suggestions how to handle .txt import with more than one line?one header and two detail?

    1. You need to have a way to identify a header and an detail line. Often the first part of the string is the identifier. You then create two line definition and specify the identifier string. Please go to for more help.

  6. Ari Z. says:

    Hi Gunnar, Is there any function to ”skip line” when importing if the value of a colum = certain value? I want to Skip all transaction with status = Declined for example.

    Thank you

    1. You should be able to map the different table and skip the mapping codeunit-> do nothing

Leave a Reply

%d bloggers like this: