Dataport-problem

tomas.barktomas.bark Member Posts: 3
Hi there.
I have a dataport that should import a fixed file but with a pretty strange build.
The file looks like this:
*******************************************
3005294210035902 0620200707100205564164357
3205294210035902 000000000000020+00
3205294210035902 000000000027200+25
3205294210035902 000000000002000+25
3105294210035902 111553 000000000000445-
3105294210035902 113310 000000000032000-
3105294210035902 113410 000000000000960-
********************************************
The first line (300) is the salesheader and the other two (320 and 310) are the saleslines. Now I can't figure out how to get the data in the tables because every line is different from each other. My idea is to define 3 dataitems (Sales Header, Sales Line and Sales Line(2)) and define the dataportfields for each dataitem.
(The dataport should loop on the 300-line...)
But I cant get it to work...:(
Does anyone have any ideas?? plez help

Comments

  • WaldoWaldo Member Posts: 3,412
    I wouldn't do it with a dataport ... but I would use a codeunit.

    Read a file line per line.
    then decide wether it is a sales header or sales line.
    then do you magic with COPYSTR, STRLEN, STRPOS, etc. :wink:

    Just a suggestion...

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
  • krikikriki Member, Moderator Posts: 9,110
    You can still use a dataport. But in it you can only put 1 field that is a text1024. In the "OnAfterImportRecord()"-trigger, you can analyze the string.
    1 limit : NO line in the file may be larger than 1024 bytes!
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • WaldoWaldo Member Posts: 3,412
    That's indeed easier (why easy when you can do it complex :oops: ).

    Then you have:
    - a dialog box for selection your file
    - a loop through your file

    I guess the 1024 chars is no problem, looking at the info he gave us.

    =D>

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
  • idiotidiot Member Posts: 651
    You need to process you data externally, eg using Excel to a more Navision friendly format so that you can save time on not programming codeunits or dataports & Navision resources...
    Only when your data is Navision friendly then you do the import...
    NAV - Norton Anti Virus

    ERP Consultant (not just Navision) & Navision challenger
  • WaldoWaldo Member Posts: 3,412
    Yes, but if you have to do that every time you receive te file ... in total it will be more work. Just program once and you'll have your function in place for the next time.

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
  • tomas.barktomas.bark Member Posts: 3
    Thanks for the replies..
    One question though...
    how do I get the codeunit to read one line? is there a special method?
  • WaldoWaldo Member Posts: 3,412
    There are many posts about that in the forum. Just use the search functionality.

    Among them, I found:
    http://www.mibuso.com/forum/viewtopic.php?t=12123
    http://www.mibuso.com/forum/viewtopic.php?t=2419
    http://www.mibuso.com/forum/viewtopic.php?t=4483
    ...

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
Sign In or Register to comment.