Hi there,
within a CodeUnit I generate a File "Production.csv". I would like to add a new line everytime into the file I run the CodeUnit!
But without the
IF EXISTS(FileNameProdZahlen) THEN
ERASE(FileNameProdZahlen);
I get the Error "The File does already exist!"
Possible?
Thanks a Lot !!
0
Comments
Hopefully this can give you an idea. I believe if you search too there was a similar post a while back that you possibly could find. Perhaps search for Add to existing text file :-k
here are some more posts
http://www.mibuso.com/forum/viewtopic.php?t=4706
http://www.mibuso.com/forum/viewtopic.php?t=13457
http://www.mibuso.com/forum/viewtopic.php?t=8364
probably more if you search
http://www.BiloBeauty.com
http://www.autismspeaks.org
I have created a Report with nested dataitems. a line of code in our business logic will call this report if a certain condition is met. The report will create a CSV file if none exists, and append to the CSV file when it does exist.
Creation of the file is clockwork. no problems. I am, however, having issues with the append. I have tried both Savatage and Xypher's suggestions, but each time i am getting appending at the start of the file, and that is no good.
I have three data items.
Integer (OnAfterGetRecord I write field label data, but only when the file is being created)
Sales Header (OnAfterGetRecord, I fill some variables with Sales Header values)
Sales Line (linked to the header, on AfterGetRecord, I fill some var. w/ data from tables linked to sales line and do my outstream.write).
On PreReport, I have the following code:
it is still early draft of code, so forgive the hard-coding.
my issue is that when i open the existing file and seek the LEN, I begin writing at the start of the file, not the end. I assume I am missing a line of code somewhere, but my search of the forum only talks about using LEN and going from there. Any thoughts on what i am doing wrong?
thanks!
A file.SEEK to LEN should be fine. here's a test with your code..
You have not shown the writing code - is it possible that another seek is affecting it?
Dynamics Nav Add-ons
http://www.simplydynamics.ie/Addons.html
here is my code for writing. it occurs in the sales line dataitem. i was using Outstream, and maybe that is my problem? your example shows POFile.WRITE....but i do a POFile.CREATEOUTSTREAM.
there is no other SEEK.
I generally use the WRITE command with text and use the OUTSTREAM with binary etc. I haven't tried a SEEK/OUTSTEAM combination before but it should work.
Two suggestions:
1. Use the WRITE command
2. Put the SEEK after creating the OUTSTREAM.
Dynamics Nav Add-ons
http://www.simplydynamics.ie/Addons.html
hello, thanks again.
I tried putting the seek after creating the OUTSTREAM, but with the same results. I will try your other idea next!
\:D/
thanks so much, DaveT!
Dynamics Nav Add-ons
http://www.simplydynamics.ie/Addons.html
http://www.BiloBeauty.com
http://www.autismspeaks.org
it did appear that the SEEK was working - i created some variables to show me what position it was on after doing the seek and the number looked correct. when it came to writing the output, however, it seemed to ignore the position altogether.