EDI File Translation Settings

To control how EDI files are being parsed, pass in either an EdifactReaderSettings or an X12ReaderSettings object to the corresponding reader.

X12ReaderSettings settings = new X12ReaderSettings();
settings.ContinueOnError = true;
settings.Encoding = Encoding.UTF8;
settings.MaxSegmentLength = 5000;
settings.Separators = Separators.X12;
settings.Split = true;

using (var ediReader = new X12Reader(edi, "Templates", settings))

You can select any of the following settings:

  • Encoding - this is the System.Encoding to use when writing to the output stream or file. UTF8 by default.
  • ContinueOnError - this is to force the parser to continue past a ReaderException. These exceptions imply that the EDI stream is corrupt and execution is terminated by default. By setting this flag to True, execution continues to recover any additional transactions or interchanges further down the stream.
  • MaxSegmentLength - this is the maximum number of characters the parser can read before finding a segment terminator. When no segment terminator was found, the parser assumes the EDI stream is corrupt and terminates execution. It is also used in VDA and positional parser to specify the set length of each segment. 5000 by default for EDIFACT and X12. 128 by default for VDA.
  • Separators - this is the set of separators to be used when reading the EDI document. It uses the default delimiter sets for X12 and EDIFACT when not explicitly set. The separators are being automatically overwritten by the delimiters set in ISA or UNA.
  • NoEnvelope - this flag tells the parser to not expect any envelopes (ISA, UNB, etc.) and that transactions only will be read from the EDI stream. 
  • Split- When a template is marked for splitting it will still be translated as if it had not been marked. To explicitly enable splitting set this to true. It's useful when you want to reuse the same template to split and no-split scenarios depending on file size.
Was this article helpful?
0 out of 1 found this helpful