Documentation

How to configure EDI Reader

Article author
Admin
  • Updated

EDI Tools for .NET translates EDI files using EDI Reader and its derived readers for every supported EDI standard. For more information on how to use EDI Reader head on to the Parse EDI files article.

All EDI readers can be configured with additional settings which change the behavior of the EDI reader.

 

Common EDI reader settings

  • Encoding - this is the System.Encoding of the EDI file. UTF8 by default.
  • ContinueOnError - this is to force the parser to continue past an exception. By default, parsing stops when an exception is encountered. 
  • 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 parsers 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 EDI separators to be used when reading EDI transactions. When used with EDI files that have valid envelopes, this property is overwritten by the delimiters found in the envelopes (ISA, UNA, MSH, etc.).
  • NoEnvelope - this flag tells the parser to not expect any envelopes (ISA, UNB, etc.) and that EDI transactions must be parsed using the delimiters specified in the Separators property. 
  • 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. 
  • LeaveOpen - whether to close the underlying stream when the reader is disposed of. False by default.

 

Apply reader settings to EDI 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))
  • EdifactReaderSettings settings = new EdifactReaderSettings ();
    settings.ContinueOnError = true;
    settings.Encoding = Encoding.UTF8;
    settings.MaxSegmentLength = 5000;
    settings.Separators = Separators.Edifact;
    settings.Split = true;

    using (var ediReader = new EdifactReader(edi, "Templates", settings))
  • Hl7ReaderSettings settings = new Hl7ReaderSettings();
    settings.ContinueOnError = true;
    settings.Encoding = Encoding.UTF8;
    settings.MaxSegmentLength = 5000;
    settings.Separators = Separators.X12;
    settings.Split = true;

    using (var ediReader = new Hl7Reader(edi, "Templates", settings))
  • NcpdpScriptReaderSettings settings = new NcpdpScriptReaderSettings();
    settings.ContinueOnError = true;
    settings.Encoding = Encoding.UTF8;
    settings.MaxSegmentLength = 5000;
    settings.Separators = Separators.NcpdpScript;
    settings.Split = true;

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

 

Edifact reader settings

The Edifact reader has an extra setting:

  • EancomS3IsDefault - By default, all EANCOM transactions for version D01B are parsed according to the EANCOM Syntax 4. When this property is set to True, then EANCOM Syntax 3 is used.

 

NCPDP Telco and VDA reader settings

NCPDP Telco and VDA standards are flat files and do not require reader settings, like separators, etc. The file encoding can be specified directly as a parameter to the reader constructor.

Share this:

Was this article helpful?

Comments

0 comments

Please sign in to leave a comment.