Documentation

How to configure EDI Writer

Article author
Admin
  • Updated

EDI Tools for .NET generates EDI files using EDI Writer and its derived writers for every supported EDI standard. For more information on how to use EDI Writer head on to the Generate EDI files article.

All EDI writers can be configured with additional settings which change the behavior of the EDI writer.

 

Common EDI writer settings

  • Encoding - this is the System.Encoding to use when writing to the output stream or file. UTF8 by default.
  • PreserveWhitespace - this is to preserve white spaces in data elements initialized with blanks. False by default.
  • Postfix - this is the postfix string to be applied at the end of each segment. Null by default.
  • Separators - this is the set of separators to be used when generating the EDI document. It uses the default delimiter sets for X12 and EDIFACT when not explicitly set. The separators can be changed at run-time by using the overloads of Write(ISA isa) or Write(UNB unb).
  • AutoTrailers - Whether to automatically apply trailers to groups and interchanges.

 

Apply writer settings to EDI writer

  • X12WriterSettings settings = new X12WriterSettings();
    settings.AutoTrailers = true;
    settings.Encoding = Encoding.UTF8;
    settings.Postfix = Environment.NewLine;
    settings.PreserveWhitespace = true;
    settings.Separators = Separators.X12;

    using (var writer = new X12Writer(stream, settings))
  • EdifactWriterSettings settings = new EdifactWriterSettings();
    settings.AutoTrailers = true;
    settings.Encoding = Encoding.UTF8;
    settings.Postfix = Environment.NewLine;
    settings.PreserveWhitespace = true;
    settings.Separators = Separators.Edifact;

    using (var writer = new EdifactWriter(stream, settings))
  • Hl7WriterSettings settings = new Hl7WriterSettings();
    settings.AutoTrailers = true;
    settings.Encoding = Encoding.UTF8;
    settings.Postfix = Environment.NewLine;
    settings.PreserveWhitespace = true;
    settings.Separators = Separators.Hl7;

    using (var writer = new Hl7Writer(stream, settings))
  • NcpdpScriptWriterSettings settings = new NcpdpScriptWriterSettings();
    settings.AutoTrailers = true;
    settings.Encoding = Encoding.UTF8;
    settings.Postfix = Environment.NewLine;
    settings.PreserveWhitespace = true;
    settings.Separators = Separators.NcpdpScript;

    using (var writer = new NcpdpScriptWriter(stream, settings))
Share this:

Was this article helpful?

Comments

0 comments

Please sign in to leave a comment.