An EDIFACT message (Electronic Data Interchange for Administration, Commerce, and Transport) is a standardized format for electronic data exchange between businesses. It is widely used for transmitting structured business documents, such as invoices, purchase orders, and shipping notices, in a machine-readable format. EDIFACT was developed by the United Nations (UN/CEFACT) and is an internationally recognized standard.
Since EDIFACT is designed as a machine-readable document format, interpreting an EDIFACT message can be quite challenging. In this article, we’ll break down the high-level structure of a typical EDIFACT message and explore its key formatting elements.
For this discussion, we will use a sample EDIFACT message representing a purchase order. To enhance readability, each segment in this example is displayed on a separate line. However, in a typical EDIFACT message, segments are not separated by line breaks unless the newline character itself is used as the segment separator.
UNA:+.? '
UNB+UNOC:3+SENDER_ID+RECEIVER_ID+240218:1200+12345'
UNH+1+ORDERS:D:96A:UN'
BGM+220+PO123456+9'
DTM+137:20240218:102'
NAD+BY+123456::91'
LIN+1++123456789:IN'
QTY+21:10'
UNT+7+1'
UNZ+1+12345'
Like most other EDI formats, EDIFACT messages are primarily composed of segments and elements. A segment is a logical grouping of related data elements, while an element represents an individual data field within a segment.
Each segment in an EDIFACT message has a unique three-letter code and consists of one or more elements that convey
specific details. Segments are separated using a segment separator/terminator character, with the apostrophe ('
)
commonly serving this purpose.
In our sample EDIFACT message, segments include UNA
, UNB
, UNH
, BGM
, DTM
, NAD
, LIN
, QTY
, UNT
, and
UNZ
. Each segment contains its own set of data elements, separated by the apostrophe ('
). For example, the DTM
segment provides Date/Time-related information for the purchase order.
DTM+137:20240218:102'
Each element within a segment represents a specific data point relevant to the information that the parent segment
conveys. Regular elements within a segment are typically separated by the plus (+
) character, while sub-elements
within a composite element are usually separated by the colon (:
) character.
For example, in our sample EDIFACT message, the BGM
(Beginning of Message) segment contains three elements: 220
,
PO123456
, and 9
, all separated by the +
character.
BGM+220+PO123456+9'
Each of these data points represents a specific detail about the message, as outlined below.
220
: Purchase order (Document type code)PO123456
: Purchase order number9
: Message function code (Original message)On the other hand, the DTM
(Date/Time) segment contains a composite element, 137:20240218:102
, which consists of
three sub-elements: 137
, 20240218
, and 102
. Just like regular elements, each of these sub-elements represents a
specific detail related to the date/time, as outlined below.
137
: Date qualifier (Order Date)20240218
: Actual date (YYYYMMDD format: 18th Feb 2024)102
: Date format qualifier (YYYYMMDD)Although the segments used in an EDIFACT message can vary depending on the message type, there are certain segments that serve specific purposes and are commonly found across all EDIFACT formats.
UNA
- This is an optional segment, which can be used to define the separators used within this particular EDIFACT
message.UNB
- Interchange header which defines the envelope of the EDIFACT message and contains information about the sender
and receiver.UNH
- Message header which marks the start of a message and contains metadata that helps in identifying and
processing the message.BGM
- Beginning of the message which provides important information such as the type of document, document number,
and message function.UNT
- Message trailer which marks the end of a message and provides important information for message validation,
specifically the number of segments in the message and the message reference number.UNZ
- Interchange trailer which closes the envelope of the EDIFACT message that was started with the UNB segment.As discussed in the previous sections of this article, an EDIFACT message includes several different separators, each serving a specific purpose. Based on the common usage of EDIFACT messages, we can identify six main types of separators.
Separator | Description | Default Character |
---|---|---|
Segment Separator | Ends a segment | ' (apostrophe) |
Element Separator | Separates elements in a segment | + (plus) |
Sub-element Separator | Separates sub-elements within a composite element | : (colon) |
Decimal Separator | Defines decimal values | . or , (dot or comma) |
Release Character | Escapes special characters | ? (question mark) |
Repetition separator | Represent multiple occurrences of a data element or composite data element within a segment | * (asterisk) |
The characters listed in the table above are the default separators defined by the EDIFACT standard. However, the
standard also allows for the use of other characters as separators, which can be defined through the optional UNA
segment we discussed earlier. The following example illustrates how the UNA segment specifies each separator.
UNA:+.?*'
UNA1
- Component data element separatorUNA2
- Data element separatorUNA3
- Decimal markUNA4
- Release characterUNA5
- Repetition separatorUNA6
- Segment terminatorIf the UNA
segment is not included in the EDIFACT message, it will be assumed that the default separators are in use.
In this article, we’ve explored how to decode and understand the high-level structure of an EDIFACT message. To gain a deeper understanding of a specific EDIFACT message, the best approach is to refer to the EDI specifications provided by your business partner for that particular message type. These specifications will help you interpret the data represented by each segment and element, as well as any data validation conditions expected by the partner.
Udith is the Chief Technology Officer at Aayu Technologies. With over 9 years of experience in the enterprise software industry, he has been instrumental in architecting, developing, and maintaining a range of enterprise software solutions, particularly B2B communication software, with a significant focus on cloud technologies.