In brief
EDI (electronic data interchange) is the automated exchange of business documents, such as purchase orders, dispatch advices and invoices, between two companies' systems in an agreed format. In Europe the foundation is UN/EDIFACT, a standard published by UNECE, and in retail its GS1 EANCOM subset. In practice an EDI rollout means three pieces of work: mapping messages to the ERP, choosing a transport (for example AS2) and testing with every partner, because each retail chain has its own implementation guide.
What EDI and UN/EDIFACT are
UNECE describes UN/EDIFACT as a set of internationally agreed standards, directories and guidelines for the electronic interchange of structured data between independent computerized information systems. The rules are published by UNECE in the UNTDID (United Nations Trade Data Interchange Directory), which includes, among other things, the syntax rules and message directories.
An EDIFACT file is layered:
- an interchange starts with a `UNB` segment and ends with `UNZ`; it carries the sender, the recipient and a control reference;
- a message starts with `UNH` and ends with `UNT`; the header states the message type and which directory version it comes from;
- segments carry the data: `BGM` document number, `DTM` dates, `NAD` parties, `LIN` line items, `QTY` quantities.
A simplified purchase order (sample numbers):
UNA:+.? '
UNB+UNOC:3+5900000000017:14+5900000000024:14+261129:0930+00000123'
UNH+1+ORDERS:D:96A:UN:EAN008'
BGM+220+ZAM-2026-0458+9'
DTM+137:20261129:102'
DTM+2:20261203:102'
NAD+BY+5900000000017::9'
NAD+SU+5900000000024::9'
LIN+1++5900000000123:SRV'
QTY+21:48'
UNS+S'
UNT+10+1'
UNZ+1+00000123'GS1 EANCOM is a subset of UN/EDIFACT that keeps only the elements needed in trade and ties them to GS1 identifiers: the GTIN for products and the GLN for locations and companies. Retail chains and logistics operators in Poland most often require exactly EANCOM.
Messages from order to invoice
A typical document flow between a supplier and a retail chain:
| Message | Name | Sent by | Purpose |
|---|---|---|---|
| ORDERS | purchase order | buyer | what, how much, when and where to deliver |
| ORDRSP | order response | supplier | confirmation, quantity or date change, line rejection |
| DESADV | despatch advice | supplier | exactly what is shipped, on which pallets, with logistics unit numbers |
| RECADV | receiving advice | buyer | what the warehouse received, with discrepancies |
| INVOIC | invoice | supplier | invoice data for automatic matching against order and delivery |
| CONTRL, APERAK | technical and application acknowledgments | recipient | whether the file passed syntax checks and whether the recipient's system accepted it |
In Poland, structured invoices are issued in KSeF (Poland's National e-Invoicing System), so the INVOIC message has to be aligned with that flow, for example as a data copy for the partner's system carrying the KSeF invoice number. System requirements are covered in the article on preparing systems for KSeF.
Transport: AS2, SFTP and VANs
The format is half of the integration. The other half is delivering the file securely:
- AS2 (RFC 4130) sends documents over HTTP with signing and encryption. The recipient returns an MDN receipt, so the sender has proof that the file arrived unaltered.
- SFTP is simpler and popular with smaller partners, but you have to build acknowledgments yourself, usually through the CONTRL message.
- Value-added networks (VANs) and EDI service providers accept documents in one format and pass them to partners in their formats and channels. You no longer maintain many connections, but you pay per message and depend on an intermediary.
EDI or API
More and more partners offer REST APIs instead of EDI files. The choice depends on the partner and the process:
| Criterion | EDI (EDIFACT, EANCOM) | API (REST, JSON) |
|---|---|---|
| Standard | one standard and directories for the whole industry | each partner has its own API contract |
| Timing | batches every few minutes or hours | request and response in seconds |
| Status on demand | you wait for the next message | you can query order status at any time |
| Large retail partners | required by default | a complement, rarely a replacement |
| Tooling | EDI translators, VAN providers | API gateways, standard HTTP libraries |
In practice a mixed model wins: business documents with large chains go through EDI, while statuses, shipment tracking and marketplace integrations go through APIs. We built a shared layer for both channels on the EDI and API integration platform for a logistics operator's customers. How to expose an API to partners without losing control of it is covered in the article on the API gateway.
Mapping to ERP and testing with the partner
Most of the effort goes not into syntax but into the meaning of fields. Each chain publishes a message implementation guide (MIG): which segments are mandatory, which codes it uses, how corrections are flagged. The mapping has to translate that into ERP data, and the principles of integrating with an ERP are covered in the article on ERP integration.
A test set for onboarding a new partner:
- Syntax: validate the file against the directory version and the MIG, and send a correct CONTRL for a faulty file.
- Master data: every GTIN and GLN in the message exists in the ERP master files. One missing code stops the whole order, which is why the master data housekeeping described in the article on MDM shortens onboarding.
- Business cases: a partially confirmed order, a date change, a short delivery, an invoice correction, a return.
- Duplicates and ordering: the same interchange control reference accepted twice, a despatch advice arriving before the order response.
- Load: the order peak before holidays or at the start of the month, when partners send batches at the same time.
- Monitoring: an alert when no ORDRSP went out for an order within the agreed time or when a partner rejected a file.
The same cases are worth automating and running on every mapping change, just like the API contract tests described in the article on contract testing.
Questions and answers
What is the difference between EDIFACT and EANCOM?
UN/EDIFACT is the general United Nations standard with message directories for trade, transport and administration. GS1 EANCOM is its subset for trade, which keeps only the elements needed in practice and links them to GS1 identifiers such as the GTIN and GLN. An EANCOM file is a valid EDIFACT file, but not every EDIFACT file meets EANCOM requirements.
Is EDI still needed now that there are APIs?
In trade with large retail chains and in logistics, yes, because partners require it in their contracts and the standard works the same way across hundreds of companies. APIs work better for real-time status and marketplace integrations. Most companies run both channels with a shared mapping layer to the ERP.
How long does it take to onboard a new EDI partner?
It depends on whether the partner uses standard EANCOM or has its own deviations, and on the state of your master data. With a ready platform and a familiar format it is usually a few days of work plus testing with the partner. A new message type or an unusual implementation guide takes longer, because it needs a new mapping and new test cases.
What are AS2 and an MDN receipt?
AS2 is a protocol defined in RFC 4130 that sends business documents over HTTP with a digital signature and encryption. After receiving a file, the recipient returns an MDN (Message Disposition Notification), usually signed. That gives the sender proof that the document arrived unaltered.