The EDIFACT syntax

Here we will have a short look to the syntax of the EDIFACT messages - especially the segments. A well defined collection of segments in a well defined sequence will result in a EDIFACT message. To drill down to the data elements, which are in the focus, we only need to look at the segments, not at the messages.

Why are the data elements so interesting

Because this are the data fields which contains the data of interest. By doing a conversion from EDIFACT to any other format, the data must remain unmodified but the form how they are put together may vary.

More abstract, converting incoming data, formed in a specific syntax, to another output format modifies the form in which the data are represented, but never the data itself. That is for example for converting the date format from YYYY-MM-DD to MM-DD-YYYY, modifying the decimal data format with decimal dot or decimal comma etc... But you see, there are the formats modified, not the data itself.

There may be programmatic exceptions to this. But they should not be hard-coded within the converter software. They should be realized in form of scripts or exit programs, in general interfaces which are used while conversion. The implementation of exit programs called by the converter at specific situations may be optional.

The EDIFACT segment

In general, the EDIFACT syntax is defined in the ISO-9735. Take a look to it at http://www.edifactory.de. It is quite irrelevant which version of this standard we are looking on - the fundamential syntax of EDIFACT has never changed. Looking on a segment, we see that it is build of data fields and sets of data fields which are called composites. For both, the segment itself and the nested composite is in common, that they are build of data fields. As a result, we have a maximal nesting level of one (1) in a segment. There is no composite nested in a composite. This limitation is special for EDIFACT segments but not for all kinds of incoming data formats. To illustrate this, just think about XML files.

As the result, keep in mind that

Grouping segments

EDIFACT segments are optionally grouped to segment groups. This segment groups contains a well defined sequence of segments, which may occur in the message if the first segment of a segment group occures. If this first segment does not occur at the defined position in the message, the hole segment group does not appear. That's a bit different to composites in a segment which may occur with empty data fields as the first data element.

The message

The message is constructed with segments and segment groups. The sequence, the number of repetations of segments or segment groups is well defined. Creating a message with randomly added segments will not match the defined sequence and therefore, the message is invalid.