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:
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.
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.
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.
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.
Have you seen http://www.codeproject.com/KB/XML/edix.aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With