Lesson 3 of 6
Building the 856 hierarchy (HL loops and DESADV CPS)
9 min
Listen to this lesson
The 856 describes a shipment as a tree. Every level of the tree is an HL (hierarchical level) segment followed by the segments that describe that level. HL01 is the level's own ID, HL02 the ID of its parent, HL03 the level code and HL04 whether children follow. The level codes that matter for a supplier ASN are S shipment, O order, T shipping tare (usually a pallet), P pack (a carton or other package) and I item.
The order of the levels is part of the partner's guide and is declared in BSN05, the hierarchical structure code: 0001 is shipment, order, packaging, item ("pick and pack"); 0002 is shipment, order, item, packaging; 0004 is shipment, order, item, with no packaging levels at all ("standard pack"). Great Lakes' guide asks for 0001, because its receiving docks scan each package label and need to know what is inside it.
What each level carries
| Level | Typical segments | Source in DELVRY07 / SAP |
|---|---|---|
| S shipment | TD1 package count and weight, TD5 carrier and routing, REF*BM bill of lading, DTM*011 shipped date, N1*ST ship-to, N1*SF ship-from | E1EDL20 (ANZPK, BTGEW, BOLNR, ROUTE), E1EDT13 006, E1ADRM1 partners |
| O order | PRF purchase order number and date | E1EDL41 (BSTNR, BSTDT) |
| T tare | MAN pallet SSCC (when the guide uses pallets of cartons) | Outer E1EDL37 whose E1EDL44 lines point to other HUs |
| P pack | MAN*GM SSCC with application identifier, PO4 or MEA if required | E1EDL37 (EXIDV, VHILM, BRGEW) |
| I item | LIN with buyer (BP) and vendor (VP) part numbers, SN1 shipped quantity and unit | E1EDL24 (KDMAT, MATNR, VRKME) and E1EDL44 (VEMNG) |
Where each 856 level gets its data. The guide decides which segments are mandatory for a partner.
Notice the inversion. In the IDoc, delivery item 10 holds all 50 pieces, and three handling units point to it with 24, 24 and 2. In the 856, each package is a parent with its own item line underneath. The map must loop over handling units, read each one's E1EDL44 lines, and write an item level per HU item, quantity from VEMNG and part numbers from the delivery item it points to. A map that loops over delivery items instead produces one item level with 50 pieces under the first package, which is syntactically valid and physically wrong.
Delivery 80001234 as an 856
GS*SH*CONTOSOMC*GLFLEETEDI*20261020*1612*912*X*004010~ST*856*0001~BSN*00*80001234*20261020*1612*0001~HL*1**S*1~TD1**3****G*1050*LB~REF*BM*1710-80001234~DTM*011*20261020*1600~N1*ST*GREAT LAKES FLEET SERVICES*92*GR04~N1*SF*CONTOSO MOTOR CO*92*1710~HL*2*1*O*1~PRF*GLF-PO-55120***20261014~HL*3*2*P*1~MAN*GM*00007123450000001016~HL*4*3*I*0~LIN**BP*GLF-ALT-100*VP*CMC-ALT-100~SN1**24*EA~… the same pattern for HL 5–8 …CTT*8*50~SE*nn*0001~
A few details are worth reading slowly. GS01 is SH, the functional identifier for ship notices (PR is the 855, PO the 850). BSN02 is the shipment ID; Contoso sends the delivery number, so one delivery is one ASN. BSN05 declares 0001. HL04 is 1 when children follow and 0 on the items. The CTT counts the HL segments (eight) and hashes the SN1 quantities (50). The weight, the bill of lading format and the SSCCs here are illustrative; the SSCCs use an example GS1 company prefix with valid check digits, which is how test data should be built.
The EDIFACT twin: DESADV
EDIFACT builds the same tree differently. Instead of numbered HL segments, the detail section repeats segment group 10, which starts with CPS (consignment packing sequence). Each CPS names its own sequence number and its parent's, so a pallet CPS can be the parent of carton CPSs, exactly like HL01 and HL02. Inside a CPS, group 11 starts with PAC (number and type of packages) and group 13 with PCI (package marks), whose GIN segment with qualifier BJ carries the serial shipping container code. Group 15 holds the line items: LIN, PIA for additional product IDs, QTY with qualifier 12 (despatch quantity) and an RFF with qualifier ON for the buyer's order number. The header has BGM with document code 351 (despatch advice) and DTM qualifier 11 for the despatch date.
| Concept | X12 856 | EDIFACT DESADV (D.96A) | DELVRY07 |
|---|---|---|---|
| Message and ID | BSN, shipment ID in BSN02 | BGM 351 with the document number | E1EDL20 VBELN |
| Despatch date | DTM*011 | DTM qualifier 11 | E1EDT13 qualifier 006 |
| Hierarchy | HL01 / HL02 / HL03 | CPS with sequence and parent number | E1EDL37 and E1EDL44 links |
| Package ID (SSCC) | MAN*GM | PCI group, GIN with BJ | E1EDL37 EXIDV |
| Buyer's order | PRF01 at order level | RFF qualifier ON | E1EDL41 BSTNR |
| Shipped quantity | SN102 / SN103 | QTY qualifier 12 | E1EDL44 VEMNG, E1EDL24 LFIMG |
What would you do?
Great Lakes reports that 856s from CMQ show all 50 alternators under the first pallet and nothing under the other two, although the IDoc has three E1EDL37 segments with correct E1EDL44 quantities. What is the most likely cause?
- HL01 is the level ID, HL02 its parent, HL03 the level (S, O, T, P, I) and HL04 whether children follow.
- BSN05 declares the structure: 0001 shipment-order-packaging-item, 0002 shipment-order-item-packaging, 0004 shipment-order-item.
- The map inverts DELVRY07: loop over handling units and their E1EDL44 items, not over delivery items.
- EDIFACT DESADV nests packages with CPS groups; PCI/GIN BJ carries the SSCC, LIN with QTY 12 the shipped quantity.
- A wrong hierarchy still gets a positive 997; only a package-by-package comparison catches it.
Check your understanding · not graded
Lesson check
1. Which BSN05 code declares the shipment, order, packaging, item structure?
2. In an 856, what does HL02 contain?
3. Which EDIFACT DESADV element carries a package's serial shipping container code?
4. Why does a map that loops over E1EDL24 produce a wrong 856 for a packed delivery?