Dataport (Importing Blank Fields)

PavlosPavlos Member Posts: 19
edited 2004-01-28 in Navision Attain
Hi to all,

I’m relatively new to navision. I’m currently facing a problem when I’m trying to import data from a csv (comma separated values) file into a table in navision. A sample of the data in the cvs file (produced by MS Excel) is as follows:

Field_1A;Field_1B;Field_1C
Field_2A;Field_2B;
Field_3A;Field_3B;
Field_4A;Field_4B;Field_4C
Field_5A;Field_5B;Field_5C
Field_6A;Field_6B;
Field_7A;Field_7B;Field_7C

Notice that at the 3rd column some fields are blank (Rows 2,3 and 6).

I’m using a dataport in order to import it into a navision table. The resulting table after running the dataport is:

Field_1A Field_1B Field_1C
Field_2A Field_2B Field_1C
Field_3A Field_3B Field_1C
Field_4A Field_4B Field_4C
Field_5A Field_5B Field_5C
Field_6A Field_6B Field_5C
Field_7A Field_7B Field_7C

Notice that the blank fields at 3rd column are filled with the value of the previous filled field (Rows 2,3, and 6). Why does this happen? It seems a bit odd to me. I want these fields to be blank as my original data. Can anybody help?

Thanks in advance,
Pavlos Papantoniou

Comments

  • eromeineromein Member Posts: 589
    you can not import blank field.

    You will have to create a new Global Variable and use it on the place you want to import the last (blank) value. Then fill your field with tha variable.

    This shoudl solve your problem.
    "Real programmers don't comment their code.
    If it was hard to write, it should be hard to understand."
  • awarnawarn Member Posts: 261
    Even better, structure your csv file as such:

    Field_1A;Field_1B;Field_1C;
    Field_2A;Field_2B;;
    Field_3A;Field_3B;;
    Field_4A;Field_4B;Field_4C;
    Field_5A;Field_5B;Field_5C;
    Field_6A;Field_6B;;
    Field_7A;Field_7B;Field_7C;

    What is happening behind the scenes is that Navision after it reads the first record is assigning Field_1A, Field_1B & Field_1C to three internal variables. When it reads the second line it does not first clear out these variables, so without the explicit ';' it does not assign a blank value to the third variable. The semicolon at the end tells Navision that it should assign the next variable.

    This will also work in the following situation:

    Field_2A;;Field_1C;

    You in fact can import blank fields, this is actual data in some cases and shouldn't be missed.

    Generally speaking with dataports you need the dividor (semicolon or comma) at the end of each line, and all values should be enclosed in double quotes. If you can get that from your client then consider yourself lucky. :)

    -A
  • Torben_R.Torben_R. Member Posts: 99
    Try INIT the record OnBeforeImportRecord.
  • PavlosPavlos Member Posts: 19
    Thank you all guys...
    all work fine... but I found better the first advice by declaring a global variable... etc

    Pavlos
Sign In or Register to comment.