EDIFACT ORDERS Purchase Order

ORDERS is the UN/EDIFACT purchase order message. A buyer sends it to a supplier to order goods or services. D96A is the directory most retail and manufacturing partners still use.

The header carries BGM (220 is an order), dates, references and NAD parties. UNS separates the header from the detail section, where each LIN group is an order line with PIA, QTY and PRI segments.

At a glance

Standard
EDIFACT
Version
D96A
Sent by
Buyer to supplier
Responses
CONTRL, ORDRSP, DESADV, INVOIC
ediFabric .NET template
TSORDERS in EdiFabric.Templates.Edifact
OpenEDI definition
View ORDERS in the spec library

ORDERS structure

The full EDIFACT ORDERS layout from its OpenEDI definition, the same model ediFabric uses to parse, validate and generate it: 54 loops and 162 segment positions, in file order. Loops are shaded and their segments indented; Max use is how many times a segment or loop may repeat.

Segment / loop Name Usage Max use
UNHMessage headerMandatory1
BGMBeginning of messageMandatory1
DTMDate/time/periodMandatory35
PAIPayment instructionsOptional1
ALIAdditional informationOptional5
IMDItem descriptionOptional1
FTXFree textOptional99
RFF loopReferenceOptional10
RFFReferenceMandatory1
DTMDate/time/periodOptional5
NAD loopName and addressOptional99
NADName and addressMandatory1
LOCPlace/location identificationOptional25
FIIFinancial institution informationOptional5
RFF loopReferenceOptional10
RFFReferenceMandatory1
DTMDate/time/periodOptional5
DOC loopDocument/message detailsOptional5
DOCDocument/message detailsMandatory1
DTMDate/time/periodOptional5
CTA loopContact informationOptional5
CTAContact informationMandatory1
COMCommunication contactOptional5
TAX loopDuty/tax/fee detailsOptional5
TAXDuty/tax/fee detailsMandatory1
MOAMonetary amountOptional1
LOCPlace/location identificationOptional5
CUX loopCurrenciesOptional5
CUXCurrenciesMandatory1
PCDPercentage detailsOptional5
DTMDate/time/periodOptional5
PAT loopPayment terms basisOptional10
PATPayment terms basisMandatory1
DTMDate/time/periodOptional5
PCDPercentage detailsOptional1
MOAMonetary amountOptional1
TDT loopDetails of transportOptional10
TDTDetails of transportMandatory1
LOC loopPlace/location identificationOptional10
LOCPlace/location identificationMandatory1
DTMDate/time/periodOptional5
TOD loopTerms of delivery or transportOptional5
TODTerms of delivery or transportMandatory1
LOCPlace/location identificationOptional2
PAC loopPackageOptional10
PACPackageMandatory1
MEAMeasurementsOptional5
PCI loopPackage identificationOptional5
PCIPackage identificationMandatory1
RFFReferenceOptional1
DTMDate/time/periodOptional5
GINGoods identity numberOptional10
EQD loopEquipment detailsOptional10
EQDEquipment detailsMandatory1
HANHandling instructionsOptional5
MEAMeasurementsOptional5
FTXFree textOptional5
SCC loopScheduling conditionsOptional10
SCCScheduling conditionsMandatory1
FTXFree textOptional5
RFFReferenceOptional5
QTY loopQuantityOptional10
QTYQuantityMandatory1
DTMDate/time/periodOptional5
APR loopAdditional price informationOptional25
APRAdditional price informationMandatory1
DTMDate/time/periodOptional5
RNGRange detailsOptional1
ALC loopAllowance or chargeOptional15
ALCAllowance or chargeMandatory1
ALIAdditional informationOptional5
DTMDate/time/periodOptional5
QTY loopQuantityOptional1
QTYQuantityMandatory1
RNGRange detailsOptional1
PCD loopPercentage detailsOptional1
PCDPercentage detailsMandatory1
RNGRange detailsOptional1
MOA loopMonetary amountOptional2
MOAMonetary amountMandatory1
RNGRange detailsOptional1
RTE loopRate detailsOptional1
RTERate detailsMandatory1
RNGRange detailsOptional1
TAX loopDuty/tax/fee detailsOptional5
TAXDuty/tax/fee detailsMandatory1
MOAMonetary amountOptional1
RCS loopRequirements and conditionsOptional100
RCSRequirements and conditionsMandatory1
RFFReferenceOptional5
DTMDate/time/periodOptional5
FTXFree textOptional5
LIN loopLine itemOptional200000
LINLine itemMandatory1
PIAAdditional product idOptional25
IMDItem descriptionOptional99
MEAMeasurementsOptional5
QTYQuantityOptional10
PCDPercentage detailsOptional5
ALIAdditional informationOptional5
DTMDate/time/periodOptional35
MOAMonetary amountOptional10
GINGoods identity numberOptional1000
GIRRelated identification numbersOptional1000
QVRQuantity variancesOptional1
DOCDocument/message detailsOptional5
PAIPayment instructionsOptional1
FTXFree textOptional99
CCI loopCharacteristic/class idOptional999
CCICharacteristic/class idMandatory1
CAVCharacteristic valueOptional10
MEAMeasurementsOptional10
PAT loopPayment terms basisOptional10
PATPayment terms basisMandatory1
DTMDate/time/periodOptional5
PCDPercentage detailsOptional1
MOAMonetary amountOptional1
PRI loopPrice detailsOptional25
PRIPrice detailsMandatory1
CUXCurrenciesOptional1
APRAdditional price informationOptional1
RNGRange detailsOptional1
DTMDate/time/periodOptional5
RFF loopReferenceOptional10
RFFReferenceMandatory1
DTMDate/time/periodOptional5
PAC loopPackageOptional10
PACPackageMandatory1
MEAMeasurementsOptional5
QTYQuantityOptional5
DTMDate/time/periodOptional5
RFF loopReferenceOptional1
RFFReferenceMandatory1
DTMDate/time/periodOptional5
PCI loopPackage identificationOptional5
PCIPackage identificationMandatory1
RFFReferenceOptional1
DTMDate/time/periodOptional5
GINGoods identity numberOptional10
LOC loopPlace/location identificationOptional9999
LOCPlace/location identificationMandatory1
QTYQuantityOptional1
DTMDate/time/periodOptional5
TAX loopDuty/tax/fee detailsOptional10
TAXDuty/tax/fee detailsMandatory1
MOAMonetary amountOptional1
LOCPlace/location identificationOptional5
NAD loopName and addressOptional99
NADName and addressMandatory1
LOCPlace/location identificationOptional5
RFF loopReferenceOptional5
RFFReferenceMandatory1
DTMDate/time/periodOptional5
DOC loopDocument/message detailsOptional5
DOCDocument/message detailsMandatory1
DTMDate/time/periodOptional5
CTA loopContact informationOptional5
CTAContact informationMandatory1
COMCommunication contactOptional5
ALC loopAllowance or chargeOptional99
ALCAllowance or chargeMandatory1
ALIAdditional informationOptional5
DTMDate/time/periodOptional5
QTY loopQuantityOptional1
QTYQuantityMandatory1
RNGRange detailsOptional1
PCD loopPercentage detailsOptional1
PCDPercentage detailsMandatory1
RNGRange detailsOptional1
MOA loopMonetary amountOptional2
MOAMonetary amountMandatory1
RNGRange detailsOptional1
RTE loopRate detailsOptional1
RTERate detailsMandatory1
RNGRange detailsOptional1
TAX loopDuty/tax/fee detailsOptional5
TAXDuty/tax/fee detailsMandatory1
MOAMonetary amountOptional1
TDT loopDetails of transportOptional10
TDTDetails of transportMandatory1
LOC loopPlace/location identificationOptional10
LOCPlace/location identificationMandatory1
DTMDate/time/periodOptional5
TOD loopTerms of delivery or transportOptional5
TODTerms of delivery or transportMandatory1
LOCPlace/location identificationOptional2
EQD loopEquipment detailsOptional10
EQDEquipment detailsMandatory1
HANHandling instructionsOptional5
MEAMeasurementsOptional5
FTXFree textOptional5
SCC loopScheduling conditionsOptional100
SCCScheduling conditionsMandatory1
FTXFree textOptional5
RFFReferenceOptional5
QTY loopQuantityOptional10
QTYQuantityMandatory1
DTMDate/time/periodOptional5
RCS loopRequirements and conditionsOptional100
RCSRequirements and conditionsMandatory1
RFFReferenceOptional5
DTMDate/time/periodOptional5
FTXFree textOptional5
STG loopStagesOptional10
STGStagesMandatory1
QTY loopQuantityOptional3
QTYQuantityMandatory1
MOAMonetary amountOptional1
UNSSection controlMandatory1
MOAMonetary amountOptional12
CNTControl totalOptional10
ALC loopAllowance or chargeOptional10
ALCAllowance or chargeMandatory1
ALIAdditional informationOptional1
MOAMonetary amountMandatory2
UNTMessage trailerMandatory1

Mandatory segments must be sent, Optional ones only when the data applies. Trading partners often add their own rules in companion guides - ediFabric templates can be adjusted to match. Open the element-level definition in the EdiNation spec library.

Sample ORDERS file

A D96A purchase order with header parties and order lines. Paste it into EdiNation to see every element named and validated.

UNB+UNOB:1+SENDER1:14:ZZUK+RECEIVER1:1:ZZUK+071101:1701+131++ORDERS++1++1'
UNH+000000101+ORDERS:D:96A:UN'
BGM+220+128576+9'
DTM+137:20020830:102'
PAI+::42'
FTX+ZZZ+1+001::91'
RFF+CT:652744'
DTM+171:20020825:102'
NAD+BY+5412345000013::9'
RFF+VA:87765432'
CTA+OC+:P FORGET'
COM+0044715632478:TE'
NAD+SU+4012345500004::9'
RFF+VA:56225432'
CUX+2:GBP:9+3:EUR:4+1.67'
DTM+134:2002080120020831:718'
TDT+20++30+31'
TOD+3++CIF:23:9'
LOC+1+BE-BRU'
LIN+1++4000862141404:SRS'
PIA+1+ABC1234:IN'
IMD+C++TU::9'
QTY+21:48'
MOA+203:699.84'
PRI+AAA:14.58:CT:AAE:1:KGM'
RFF+PL:AUG93RNG04'
DTM+171:20020801:102'
PAC+2+:51+CS'
PCI+14'
LOC+7+3312345502000::9'
QTY+11:24'
DTM+2:20020915:102'
LOC+7+3312345501003::9'
QTY+11:24'
DTM+2:20020913:102'
TAX+7+VAT+++:::17.5+S'
UNS+S'
CNT+2:1'
UNT+38+000000101'
UNZ+1+131'

The same ORDERS as JSON

ediFabric turns every loop, segment and element into a named field. This is the transaction from the sample, in the JSON that ediFabric Native and Cloud return and accept.

{
  "UNH": {
    "MessageReferenceNumber_01": "000000101",
    "MessageIdentifier_02": {
      "MessageType_01": "ORDERS",
      "MessageVersionNumber_02": "D",
      "MessageReleaseNumber_03": "96A",
      "ControllingAgencyCoded_04": "UN"
    }
  },
  "BGM": {
    "DOCUMENTMESSAGENAME_01": {
      "Documentmessagenamecoded_01": "220"
    },
    "Documentmessagenumber_02": "128576",
    "Messagefunctioncoded_03": "9"
  },
  "DTM": [
    {
      "DATETIMEPERIOD_01": {
        "Datetimeperiodqualifier_01": "137",
        "Datetimeperiod_02": "20020830",
        "Datetimeperiodformatqualifier_03": "102"
      }
    }
  ],
  "PAI": {
    "PAYMENTINSTRUCTIONDETAILS_01": {
      "Paymentmeanscoded_03": "42"
    }
  },
  "FTX": [
    {
      "Textsubjectqualifier_01": "ZZZ",
      "Textfunctioncoded_02": "1",
      "TEXTREFERENCE_03": {
        "Freetextcoded_01": "001",
        "Codelistresponsibleagencycoded_03": "91"
      }
    }
  ],
  "RFFLoop": [
    {
      "RFF": {
        "REFERENCE_01": {
          "Referencequalifier_01": "CT",
          "Referencenumber_02": "652744"
        }
      },
      "DTM": [
        {
          "DATETIMEPERIOD_01": {
            "Datetimeperiodqualifier_01": "171",
            "Datetimeperiod_02": "20020825",
            "Datetimeperiodformatqualifier_03": "102"
          }
        }
      ]
    }
  ],
  "NADLoop": [
    {
      "NAD": {
        "Partyqualifier_01": "BY",
        "PARTYIDENTIFICATIONDETAILS_02": {
          "Partyididentification_01": "5412345000013",
          "Codelistresponsibleagencycoded_03": "9"
        }
      },
      "RFFLoop": [
        {
          "RFF": {
            "REFERENCE_01": {
              "Referencequalifier_01": "VA",
              "Referencenumber_02": "87765432"
            }
          }
        }
      ],
      "CTALoop": [
        {
          "CTA": {
            "Contactfunctioncoded_01": "OC",
            "DEPARTMENTOREMPLOYEEDETAILS_02": {
              "Departmentoremployee_02": "P FORGET"
            }
          },
          "COM": [
            {
              "COMMUNICATIONCONTACT_01": {
                "Communicationnumber_01": "0044715632478",
                "Communicationchannelqualifier_02": "TE"
              }
            }
          ]
        }
      ]
    },
    {
      "NAD": {
        "Partyqualifier_01": "SU",
        "PARTYIDENTIFICATIONDETAILS_02": {
          "Partyididentification_01": "4012345500004",
          "Codelistresponsibleagencycoded_03": "9"
        }
      },
      "RFFLoop": [
        {
          "RFF": {
            "REFERENCE_01": {
              "Referencequalifier_01": "VA",
              "Referencenumber_02": "56225432"
            }
          }
        }
      ]
    }
  ],
  "CUXLoop": [
    {
      "CUX": {
        "CURRENCYDETAILS_01": {
          "Currencydetailsqualifier_01": "2",
          "Currencycoded_02": "GBP",
          "Currencyqualifier_03": "9"
        },
        "CURRENCYDETAILS_02": {
          "Currencydetailsqualifier_01": "3",
          "Currencycoded_02": "EUR",
          "Currencyqualifier_03": "4"
        },
        "Rateofexchange_03": "1.67"
      },
      "DTM": [
        {
          "DATETIMEPERIOD_01": {
            "Datetimeperiodqualifier_01": "134",
            "Datetimeperiod_02": "2002080120020831",
            "Datetimeperiodformatqualifier_03": "718"
          }
        }
      ]
    }
  ],
  "TDTLoop": [
    {
      "TDT": {
        "Transportstagequalifier_01": "20",
        "MODEOFTRANSPORT_03": {
          "Modeoftransportcoded_01": "30"
        },
        "TRANSPORTMEANS_04": {
          "Typeofmeansoftransportidentification_01": "31"
        }
      }
    }
  ],
  "TODLoop": [
    {
      "TOD": {
        "Termsofdeliveryortransportfunctioncoded_01": "3",
        "TERMSOFDELIVERYORTRANSPORT_03": {
          "Termsofdeliveryortransportcoded_01": "CIF",
          "Codelistqualifier_02": "23",
          "Codelistresponsibleagencycoded_03": "9"
        }
      },
      "LOC": [
        {
          "Placelocationqualifier_01": "1",
          "LOCATIONIDENTIFICATION_02": {
            "Placelocationidentification_01": "BE-BRU"
          }
        }
      ]
    }
  ],
  "LINLoop": [
    {
      "LIN": {
        "Lineitemnumber_01": "1",
        "ITEMNUMBERIDENTIFICATION_03": {
          "Itemnumber_01": "4000862141404",
          "Itemnumbertypecoded_02": "SRS"
        }
      },
      "PIA": [
        {
          "Productidfunctionqualifier_01": "1",
          "ITEMNUMBERIDENTIFICATION_02": {
            "Itemnumber_01": "ABC1234",
            "Itemnumbertypecoded_02": "IN"
          }
        }
      ],
      "IMD": [
        {
          "Itemdescriptiontypecoded_01": "C",
          "ITEMDESCRIPTION_03": {
            "Itemdescriptionidentification_01": "TU",
            "Codelistresponsibleagencycoded_03": "9"
          }
        }
      ],
      "QTY": [
        {
          "QUANTITYDETAILS_01": {
            "Quantityqualifier_01": "21",
            "Quantity_02": "48"
          }
        }
      ],
      "MOA": [
        {
          "MONETARYAMOUNT_01": {
            "Monetaryamounttypequalifier_01": "203",
            "Monetaryamount_02": "699.84"
          }
        }
      ],
      "PRILoop": [
        {
          "PRI": {
            "PRICEINFORMATION_01": {
              "Pricequalifier_01": "AAA",
              "Price_02": "14.58",
              "Pricetypecoded_03": "CT",
              "Pricetypequalifier_04": "AAE",
              "Unitpricebasis_05": "1",
              "Measureunitqualifier_06": "KGM"
            }
          }
        }
      ],
      "RFFLoop": [
        {
          "RFF": {
            "REFERENCE_01": {
              "Referencequalifier_01": "PL",
              "Referencenumber_02": "AUG93RNG04"
            }
          },
          "DTM": [
            {
              "DATETIMEPERIOD_01": {
                "Datetimeperiodqualifier_01": "171",
                "Datetimeperiod_02": "20020801",
                "Datetimeperiodformatqualifier_03": "102"
              }
            }
          ]
        }
      ],
      "PACLoop": [
        {
          "PAC": {
            "Numberofpackages_01": "2",
            "PACKAGINGDETAILS_02": {
              "Packagingrelatedinformationcoded_02": "51"
            },
            "PACKAGETYPE_03": {
              "Typeofpackagesidentification_01": "CS"
            }
          },
          "PCILoop": [
            {
              "PCI": {
                "Markinginstructionscoded_01": "14"
              }
            }
          ]
        }
      ],
      "LOCLoop": [
        {
          "LOC": {
            "Placelocationqualifier_01": "7",
            "LOCATIONIDENTIFICATION_02": {
              "Placelocationidentification_01": "3312345502000",
              "Codelistresponsibleagencycoded_03": "9"
            }
          },
          "QTY": {
            "QUANTITYDETAILS_01": {
              "Quantityqualifier_01": "11",
              "Quantity_02": "24"
            }
          },
          "DTM": [
            {
              "DATETIMEPERIOD_01": {
                "Datetimeperiodqualifier_01": "2",
                "Datetimeperiod_02": "20020915",
                "Datetimeperiodformatqualifier_03": "102"
              }
            }
          ]
        },
        {
          "LOC": {
            "Placelocationqualifier_01": "7",
            "LOCATIONIDENTIFICATION_02": {
              "Placelocationidentification_01": "3312345501003",
              "Codelistresponsibleagencycoded_03": "9"
            }
          },
          "QTY": {
            "QUANTITYDETAILS_01": {
              "Quantityqualifier_01": "11",
              "Quantity_02": "24"
            }
          },
          "DTM": [
            {
              "DATETIMEPERIOD_01": {
                "Datetimeperiodqualifier_01": "2",
                "Datetimeperiod_02": "20020913",
                "Datetimeperiodformatqualifier_03": "102"
              }
            }
          ]
        }
      ],
      "TAXLoop": [
        {
          "TAX": {
            "Dutytaxfeefunctionqualifier_01": "7",
            "DUTYTAXFEETYPE_02": {
              "Dutytaxfeetypecoded_01": "VAT"
            },
            "DUTYTAXFEEDETAIL_05": {
              "Dutytaxfeerate_04": "17.5"
            },
            "Dutytaxfeecategorycoded_06": "S"
          }
        }
      ]
    }
  ],
  "UNS": {
    "Sectionidentification_01": "S"
  },
  "CNT": [
    {
      "CONTROL_01": {
        "Controlqualifier_01": "2",
        "Controlvalue_02": "1"
      }
    }
  ],
  "UNT": {
    "NumberofSegmentsinaMessage_01": "38",
    "MessageReferenceNumber_02": "000000101"
  }
}

Parse and validate an ORDERS file

Read the file into typed objects with ediFabric .NET, or post it to the ediFabric Cloud REST API from any language and get JSON back.

using EdiFabric.Templates.EdifactD96A;

License.SetSerial("YOUR_SERIAL_KEY");

using (var stream = File.OpenRead(@"C:\edi\PurchaseOrder.txt"))
using (var reader = new EdifactReader(stream, "EdiFabric.Templates.Edifact"))
{
    var items = await reader.ReadToEndAsync();
    foreach (var transaction in items.OfType<TSORDERS>())
    {
        if (transaction.IsValid(out MessageErrorContext errors))
            Console.WriteLine($"{transaction.UNH.MessageReferenceNumber_01} is valid");
        else
            Console.WriteLine(string.Join(Environment.NewLine, errors.Flatten()));
    }
}
curl -X POST 'https://api.edination.com/v2/edifact/read' \
-H 'Ocp-Apim-Subscription-Key: YOUR_SERIAL_KEY' \
-H 'Content-Type: application/octet-stream' \
--data-binary '@PurchaseOrder.txt'

Generate an ORDERS file

Populate a TSORDERS object in .NET, or post JSON in the shape shown above to ediFabric Cloud, and get a valid ORDERS file back.

using EdiFabric.Templates.EdifactD96A;

License.SetSerial("YOUR_SERIAL_KEY");

var transaction = new TSORDERS();

//  Message header
transaction.UNH = new UNH();
transaction.UNH.MessageReferenceNumber_01 = "0001";
transaction.UNH.MessageIdentifier_02 = new S009();
transaction.UNH.MessageIdentifier_02.MessageType_01 = "ORDERS";
transaction.UNH.MessageIdentifier_02.MessageVersionNumber_02 = "D";
transaction.UNH.MessageIdentifier_02.MessageReleaseNumber_03 = "96A";
transaction.UNH.MessageIdentifier_02.ControllingAgencyCoded_04 = "UN";

//  Order number 128576
transaction.BGM = new BGM();
transaction.BGM.DOCUMENTMESSAGENAME_01 = new C002();
transaction.BGM.DOCUMENTMESSAGENAME_01.Documentmessagenamecoded_01 = "220";
transaction.BGM.Documentmessagenumber_02 = "128576";
transaction.BGM.Messagefunctioncoded_03 = "9";

//  Repeating DTM
transaction.DTM = new List<DTM>();

// ... set the remaining loops and segments the same way

// SegmentBuilders is in the Common project of the example repository
using (var stream = new MemoryStream())
{
    using (var writer = new EdifactWriter(stream))
    {
        writer.Write(SegmentBuilders.BuildUnb("1"));
        writer.Write(transaction);
    }
    Console.WriteLine(Encoding.UTF8.GetString(stream.ToArray()));
}
# the JSON returned by /read, edited or produced by your application
curl -X POST 'https://api.edination.com/v2/edifact/write' \
-H 'Ocp-Apim-Subscription-Key: YOUR_SERIAL_KEY' \
-H 'Content-Type: application/json' \
--data-binary '@PurchaseOrder.json' \
-o 'PurchaseOrder.txt'

ORDERS questions

What is the difference between EDIFACT ORDERS and EANCOM ORDERS?

EANCOM is the GS1 subset of EDIFACT. EANCOM ORDERS uses the same segments but only those GS1 users need, with GS1 identifiers such as GLN and GTIN.

What does UNS mean in an ORDERS message?

UNS+S separates the header section from the detail section. Everything after it belongs to the line items until the summary section.

What is the X12 equivalent?

The X12 850 purchase order.

How do I parse and generate EDIFACT ORDERS files in .NET?

In .NET, install EdiFabric and EdiFabric.Templates.Edifact, read the file with EdifactReader into TSORDERS objects and write them back with EdifactWriter. From any other language, post the file to the ediFabric Cloud REST API, which returns the same structure as JSON and converts JSON back to EDIFACT.

Parse your first ORDERS in five minutes

The Community plan is free forever and needs no credit card. It includes ediFabric .NET, Native and Cloud.