Append IFTSTA messages into same interchange.
We are working for a while with ediFabric and are pleased with it, however now we are running into an issue. We have gotten the request to write multiple IFTSTA messages in 1 file with 1 interchange (UNB, UNH).
Is there a way to do this, I was working with reading and writing, but somehow couldn't figure it out.
How to combine the reading with the writing to the same file. In general, the setup will be writing a message every second so I have to consider locking of the file.
You can write any number of messages to a stream. If you know how to do it with one then you know how to do it with more, just write each message to the stream. In the SDK (download from here), you can find multiple examples on writing EDI messages.
This one in particular, WriteMultipleInvoices() example, shows how to write two transactions.
Thank you, in this situation, you write all of them at the same time to a file.
What i am looking at is, that at 8am, we start the file with interchange and 1 message
at 8:05am we append a message to the file.
At 8:10am we append a message and close the interchange
Now based on this i could read the file, empty it and rewrite it. But is there another way? that just adds a message to an existing interchange in a file
If you need to write messages to the same file at different times, then you can't use the writer as it automatically closes the headers.
So you'll have to build UNB segment yourself as a string (we can add this feature in the next version) and do:
1. Create UNB as string and write it to a file, let's say C:\myfile.txt
2. After some time, create an instance of TSIFTSTA
3. Turn it to a string, set separators, postfixes, etc, if you need to in EdifactWriterSettings
4. Append the string to the file
5. After some time create another iftsta and append it to the file:
6. Append as many IFTSTA as you need...
7. Manually create a UNZ as a string and write it to the end of the file (either maintain a counter or count the UNH occurrences in the file):
Thank you, i got it working.
Please sign in to leave a comment.