You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I downloaded EDI.NET and was trying to parse 2 different EDI x12 documents, both 850's.
One parsed successfully, one didn't.
The one that didn't I noticed had CRLF characters in the file. The one that parsed just fine did not have these, and I saw where the default grammar settings for x12 choked on the CRLF in another issue someone raised.
I saw about the custom grammar but I'm failing to understand how this is going to be able to handle both files. Is it simpler just to take the file, strip out the CRLF characters and parse that resulting file?
The text was updated successfully, but these errors were encountered:
Hi @BrentWhiteNC and thank you for your interest in the library.
This makes total sense. You can check a related disucssion and an open issue #19. There it is mentioned that in X12 transmissions the first 106 characters are part of what is called "INTERCHANGE CONTROL HEADER" and in there, in specific positions there is the information about all "control characters" otherwise known as "delimiters" needed to parse the file. The first 106 characters no more no less are always inside a transmission.
However for X12 the EDI.Net does not auto discover the delimiters (in other formats like EDIFact it does) so one has to do this manualy through using the SetAdvise on the EDIGrammar of your choice. This is usually no biggie as in each integration with a customer the delimiters are aggreged upfront so you know what to expect and you configure you grammar accordingly.
use the following in case your segment terminator is actually a new line char instead of the default ~
So for your actual question. How can you know if you got two files which one is using what kind of delimiters so you can set up your grammar conditionally before parsing. You can either
a) store the configuration in a configfile/database of your choice per vendor and load that up to the grammar before parsing using the grammar.SetAdvice(....) . OR
b) discover it dynamically as follows:
You can try and open the file with a StreamReader and check the 106th character (segment terminator) as stated in the ISA 106 spec
After you know your delimiter use the grammar.SetAdvice(....) method to alter the segment terminator as needed.
Lastly you should reset the stream position to zero stream.Position = 0; and pass it to the EDI net for deserialization
Of course you can find in there the other characters as well.
Hope this helped.
PS: Again this should be automatically discovered in the library but have not found time to do so yet.
I downloaded EDI.NET and was trying to parse 2 different EDI x12 documents, both 850's.
One parsed successfully, one didn't.
The one that didn't I noticed had CRLF characters in the file. The one that parsed just fine did not have these, and I saw where the default grammar settings for x12 choked on the CRLF in another issue someone raised.
I saw about the custom grammar but I'm failing to understand how this is going to be able to handle both files. Is it simpler just to take the file, strip out the CRLF characters and parse that resulting file?
The text was updated successfully, but these errors were encountered: