Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EDI Flat File parsing with C#?

Tags:

Initially I was thinking to use SSIS to parse an EDI file, however I've seen a few manual EDI parsers (field mapping), and would like to use automate this functionality in C#.

Example EDI File:

Example EDI File

like image 339
ElHaix Avatar asked Jan 12 '10 03:01

ElHaix


People also ask

Is EDI a flat file?

EDI, or Electronic Data Interchange, is a flat file format that B2B (Business-to-Business) trading partners use to send and receive business transactions. Most trading partners who exchange EDI files are in specific industries where the documents needing to be exchanged must be EDI-compliant.

What is EDI parsing?

Parsing EDI means that each segment in an EDI transaction can be uniquely mapped to a segment in its corresponding EDI format. The parser compares segments from the EDI file to segments from the EDI guideline to find a match.

What is EdiFabric?

EdiFabric is a software development kit for .NET Framework and .NET Core, which makes it straightforward to parse, generate, validate, acknowledge, split, customize, or in other words, to programmatically manipulate EDI files.


2 Answers

There is EDI.Net library which is opensource and supports all three known EDI formats (X12, EDIFact, Tradacoms). In your case for X12 you need to provide a custom implementation of the IEdiGrammar with the following presets.

public class EDI_X12Grammar : IEdiGrammar
{
...
}

var grammar = new EDI_X12Grammar() 
       {
            ComponentDataElementSeparator = new[] { '>' },
            DataElementSeparator = new[] { '*' },
            DecimalMark = null,
            ReleaseCharacter = null,
            Reserved = new char[0],
            SegmentTerminator = '~',
            ServiceStringAdviceTag = null,
            InterchangeHeaderTag = "ISA",
            FunctionalGroupHeaderTag = "GS",
            MessageHeaderTag = "ST",
            MessageTrailerTag = "SE",
            FunctionalGroupTrailerTag = "GE",
            InterchangeTrailerTag = "IEA",
        };

Disclaimer I wrote the library.

like image 121
cleftheris Avatar answered Oct 10 '22 21:10

cleftheris


Have you seen http://www.codeproject.com/KB/XML/edix.aspx

like image 33
Joe Avatar answered Oct 10 '22 19:10

Joe