Is there a really simple way to process EDIFACT for example D96A?

Parsing EDIFACT is actually not that complicated. Just split at the sytax chars: first at ' to get the segments, than at + to get data elements of that segments and at : to get the individual components. You need to take care of escaped seperator chars, of course. The chars used here are only the default, they can be changed at the beginning of the message by the optional UNA-segment. Actually the wikipedia article on EDIFACT gives a pretty good (but brief) introduction to that. And the format is documented with detail on the UN's UNECE site (yes, that's a lot and hard to read).

The tricky part is to get the information out of that and into your application (and verifying it's valid, leave alone creating good error messages). If you really plan to write a comlete parser out of nothing for all that in any language, then: No, there is no easy way to do this. Nor is there for any other flexible data representation. That is a difficult task and always will be.

But here's an idea: if you are into XML that much (or any other "modern technology" as you like to call it...). It would be a relatively easy task to write some program that converts EDIFACT messages into some unified XML-EDIFACT-Format (which is a pretty horrible thing and would most likely freak me out). You can convert every EDIFACT segment into one XML tag, maybe like this:

ERC+A7V:1:AMD'
IFT+3+NO MORE FLIGHTS'

In XML:

<segment qualifier="ERC">
    <element>
        <component>A7V</component>
        <component>1</component>
        <component>AMD<component>
    </element>
</segment>
<segment qualifier="IFT">
   <element>
       <component>3</component>
   </element>
   <element>
       <component>NO MORE FLIGHTS</component>
   </element>
</segment>

Then you can unleash the power of your XML tools and libraries on it to validate/evaluate it.

You could also do it more specific, like this:

<segment_ERC>
    <element>
        <component>A7V</component>
        <component>1</component>
        <component>AMD<component>
    </element>
</segment_ERC>
<segment_IFT>
   <element>
       <component>3</component>
   </element>
   <element>
       <component>NO MORE FLIGHTS</component>
   </element>
</segment_IFT>

This could make validation via XSD easier. You can get of course as specific as you want with this conversation, but you would sooner or later come to a point, where you would need to put information on the structure of your currently parsed message into the converter (since it is not trivial to know which segments are nested into other segments grouping them. There's not just UNG, UNH and such, but also some segment groups that you don't see directly).

Still, you will have to create specific evaluation programs/schemas/whatevers for the messages you receive, according to the EDIFACT-handbooks you should get as documentation.


I suggest searching and perusing through GitHub or SourceForge repos. A quick search with keywords: +EDIFACT +D96A provided several libraries to choose from. In fact this looks promising for your case:

  • Bots open source edi translator, http://sourceforge.net/projects/bots/. Project's description says it's a complete translator for EDI (Electronic Data Interchange).

You could always evaluate and check out Oracle B2B 11g which is part of Oracle SOA Suite 11gR1: - http://www.oracle.com/technetwork/middleware/soasuite/downloads/downloads-085394.html#11g. It has UN/EDIFACT OTD library which I guess you could use at least for parsing.

Generally your best bet is to pick up existing library and either port it to NAV or use through external interface where data flows into your NAV database. If you're able to call .NET code then a plethora of existing libraries should exist and simply by referencing assembly gets you there. As it I'm not familiar with NAV development but using some sort of REST/JSON whatever your data transfer object calling mechanism is should be possible - where your component B does the heavy job and your NAV component pulls parsed UN/EDIFACT messages through your XML interface.

There was another similar question and couple answers as well that could suit you as well: Is there any good open source EDIFACT parser in Java?.

edifact navision x12 xml edi d96a

Cheers!

Tags:

Edifact