Dataport - force append

FishermanFisherman Member Posts: 456
A really quick question here.

I've been looking through the online help and trying to see if there is any way to programmatically force a dataport to append to an existing file on export. I'd need to export data into a fixed-width, proprietary format file that is structured in a Header, Line, Trailer format (one header, multiple lines, one trailer per file). The dataports make for a nice tool since they will manage field widths in an easy-to-read format. Since the indented data items won't get me there (since it's not UPXML or for User Portal), I was going to try to string three dataports together, one for header, one for lines, and one for trailer, but I can't figure out how to force dataports 2 and 3 to append rather than replace the file created in dataport 1.

If all else fails, I can fall back on a report to do the job, but I was hoping that there was some trick that I don't know about. Any ideas?

Comments

  • kapamaroukapamarou Member Posts: 1,152
    You could always try calling each dataport through code and after each dataport, again through code, copy the contents of each produced file to a new file...
  • FishermanFisherman Member Posts: 456
    True. I might try that. Thanks for the suggestion.
  • matttraxmatttrax Member Posts: 2,309
    There is no way to do that through a dataport. Using the PADSTR function it is pretty easy to create a fixed length data file.
  • BeliasBelias Member Posts: 2,998
    kapamarou wrote:
    You could always try calling each dataport through code and after each dataport, again through code, copy the contents of each produced file to a new file...
    this can help
    http://www.mibuso.com/forum/viewtopic.php?f=23&t=36141&hilit=append+text+file
    generate the three files and then connect them
    maybe you have to play with one or two carriage returns...
    P.S.: indents are not possible in dataports
    let us know if it works
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • FishermanFisherman Member Posts: 456
    Belias -

    Thanks for the link. For the moment, I've decided it may be less of a headache to just use linked data items in a report and write out to a file using an outstream and bigtext. It was my backup plan, and really just wanted to use the dataports because of the built-in width enforcement in the fixed width option - it's just a little easier to interpret than scanning through a bunch of C/AL.

    If this looks like it's not heading in the direction that I want it to, I'll try some other methods and post back.
  • zoranpzoranp Member Posts: 3
    Hi,

    Why don't you simply generate three DataItems in one dataport - one for header, one for lines and one for trailer. You don't indent the dataitems and you can copy filters from header to the other two DataItems. With the use of two dataport properties RecordSeparator and DataItemSeparator you can control separator between records of the same dataitem and separator between two different dataitems.
  • danlindstromdanlindstrom Member Posts: 130
    Hi Fisherman

    Are you a developer with partner license?
    If so I rekomend you to create a codeunit that exports your data to the textfile.
    Dataports have some avdantages, in this case they give more headache than advantage

    I belive that mattrax is speaking in same terms by using PADSTR
    Regards
    Dan Lindström
    NCSD Navision 2.00 since 1999 (Navision Certified Solution Developer)
    MBSP Developer for Microsoft Dynamics NAV 2009
Sign In or Register to comment.