X12 856 Ship Notice/Manifest (ASN) Last updated: 2026-09-29
The 856 is the X12 ship notice/manifest, better known as the advance ship notice or ASN. Suppliers send it when goods ship so the buyer can plan receiving and match cartons to orders.
It is built from HL loops: shipment, then order, then tare (pallet) and pack (carton), then item. Carton labels are identified by their GS1 SSCC in MAN segments.
At a glance
- Standard
- X12
- Version
004010- Functional group
SH(GS01)- Sent by
- Supplier to buyer
- Responses
- 997, 861
- ediFabric .NET template
TS856inEdiFabric.Templates.X12- OpenEDI definition
- View 856 in the spec library
856 structure
The full X12 856 layout from its OpenEDI definition, the same model ediFabric uses to parse, validate and generate it: 7 loops and 58 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 |
|---|---|---|---|
ST | Transaction Set Header | Mandatory | 1 |
BSN | Beginning Segment for Ship Notice | Mandatory | 1 |
DTM | Date/Time Reference | Optional | 10 |
| HL loop | Hierarchical Level | Mandatory | 200000 |
HL | Hierarchical Level | Mandatory | 1 |
LIN | Item Identification | Optional | 1 |
SN1 | Item Detail (Shipment) | Optional | 1 |
SLN | Subline Item Detail | Optional | 1000 |
PRF | Purchase Order Reference | Optional | 1 |
PO4 | Item Physical Details | Optional | 1 |
PID | Product/Item Description | Optional | 200 |
MEA | Measurements | Optional | 40 |
PWK | Paperwork | Optional | 25 |
PKG | Marking, Packaging, Loading | Optional | 25 |
TD1 | Carrier Details (Quantity and Weight) | Optional | 20 |
TD5 | Carrier Details (Routing Sequence/Transit Time) | Optional | 12 |
TD3 | Carrier Details (Equipment) | Optional | 12 |
TD4 | Carrier Details (Special Handling, or Hazardous Materials, or Both) | Optional | 5 |
TSD | Assigned Identification, Position | Optional | 1 |
REF | Reference Identification | Optional | >1 |
PER | Administrative Communications Contact | Optional | 3 |
| LH1 loop | Hazardous Identification Information | Optional | 100 |
LH1 | Hazardous Identification Information | Mandatory | 1 |
LH2 | Hazardous Classification Information | Optional | 4 |
LH3 | Hazardous Material Shipping Name | Optional | 12 |
LFH | Freeform Hazardous Material Information | Optional | 20 |
LEP | EPA-Required Data | Optional | >1 |
LH4 | Canadian Dangerous Requirements | Optional | 1 |
LHT | Transborder Hazardous Requirements | Optional | 3 |
LHR | Hazardous Material Identifying Reference Numbers | Optional | 10 |
PER | Administrative Communications Contact | Optional | 5 |
LHE | Empty Equipment Hazardous Material Information | Optional | 1 |
| CLD loop | Load Detail | Optional | 200 |
CLD | Load Detail | Mandatory | 1 |
REF | Reference Identification | Optional | 200 |
DTP | Date or Time or Period | Optional | 1 |
MAN | Marks and Numbers | Optional | >1 |
DTM | Date/Time Reference | Optional | 10 |
FOB | F.O.B. Related Instructions | Optional | 1 |
PAL | Pallet Information | Optional | 1 |
| N1 loop | Name | Optional | 200 |
N1 | Name | Mandatory | 1 |
N2 | Additional Name Information | Optional | 2 |
N3 | Address Information | Optional | 2 |
N4 | Geographic Location | Optional | 1 |
REF | Reference Identification | Optional | 12 |
PER | Administrative Communications Contact | Optional | 3 |
FOB | F.O.B. Related Instructions | Optional | 1 |
SDQ | Destination Quantity | Optional | 50 |
ETD | Excess Transportation Detail | Optional | 1 |
CUR | Currency | Optional | 1 |
| SAC loop | Service, Promotion, Allowance, or Charge Information | Optional | >1 |
SAC | Service, Promotion, Allowance, or Charge Information | Mandatory | 1 |
CUR | Currency | Optional | 1 |
GF | Furnished Goods and Services | Optional | 1 |
YNQ | Yes/No Question | Optional | 10 |
| LM loop | Code Source Information | Optional | 10 |
LM | Code Source Information | Mandatory | 1 |
LQ | Industry Code | Mandatory | 100 |
| V1 loop | Vessel Identification | Optional | >1 |
V1 | Vessel Identification | Mandatory | 1 |
R4 | Port or Terminal | Optional | >1 |
DTM | Date/Time Reference | Optional | >1 |
CTT | Transaction Totals | Optional | 1 |
SE | Transaction Set Trailer | Mandatory | 1 |
Sample 856 file
A ship notice with shipment, order, pack and item levels. Paste it into EdiNation to see every element named and validated.
ISA*00* *00* *16*SENDER1 *14*RECEIVER1 *071216*1406*U*00204*000000263*1*T*>~ GS*IN*SENDER1*RECEIVER1*20071216*1406*000000001*X*004010~ ST*856*0001~ BSN*00*01140824*20051015*1345*0001~ HL*1**S~ TD1*CTN25*2****G*45582*LB*1000*CF~ TD5*B*2*JBHT*M~ TD3*TL*ABCD*07213567******30394938483234~ REF*BM*01140824~ REF*CN*082131~ REF*CR*01082131~ DTM*011*200~ N1*ST*WAL-MART DC 6094J-JIT*UL*0078742035260~ N1*SF*SUPPLIER NAME~ HL*2*1*O~ PRF*9988776655***20051015~ REF*IA*211555050~ REF*DP*00005~ REF*MR*0073~ REF*IV*01140824~ N1*BY*WAL-MART STORES,INC.*UL*0078742000992~ HL*3*2*P~ MAN*GM*00000010012345614785~ HL*4*3*I~ LIN**UP*008815509183~ SN1**4*EA~ HL*5*3*I~ LIN**UP*008815547321~ SN1**9*EA~ HL*6*1*O~ PRF*2288115555***20051015~ REF*IA*211555050~ REF*DP*00005~ REF*MR*0073~ REF*IV*01140824~ N1*BY*WAL-MART STORES,INC.*UL*0078742000015~ HL*7*6*P~ MAN*GM*00000010012378945698~ HL*8*7*I~ LIN**UP*008815509183~ SN1**4*EA~ HL*9*7*I~ LIN**UP*008815547321~ SN1**9*EA~ CTT*9~ SE*44*0001~ GE*2*000000001~ IEA*1*000000263~
The same 856 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.
{
"ST": {
"TransactionSetIdentifierCode_01": "856",
"TransactionSetControlNumber_02": "0001"
},
"BSN": {
"TransactionSetPurposeCode_01": "00",
"ShipmentIdentification_02": "01140824",
"Date_03": "20051015",
"Time_04": "1345",
"HierarchicalStructureCode_05": "0001"
},
"HLLoop": [
{
"HL": {
"HierarchicalIDNumber_01": "1",
"HierarchicalLevelCode_03": "S"
},
"TD1": [
{
"PackagingCode_01": "CTN25",
"LadingQuantity_02": "2",
"WeightQualifier_06": "G",
"Weight_07": "45582",
"UnitorBasisforMeasurementCode_08": "LB",
"Volume_09": "1000",
"UnitorBasisforMeasurementCode_10": "CF"
}
],
"TD5": [
{
"RoutingSequenceCode_01": "B",
"IdentificationCodeQualifier_02": "2",
"IdentificationCode_03": "JBHT",
"TransportationMethodTypeCode_04": "M"
}
],
"TD3": [
{
"EquipmentDescriptionCode_01": "TL",
"EquipmentInitial_02": "ABCD",
"EquipmentNumber_03": "07213567",
"SealNumber_09": "30394938483234"
}
],
"REF": [
{
"ReferenceIdentificationQualifier_01": "BM",
"ReferenceIdentification_02": "01140824"
},
{
"ReferenceIdentificationQualifier_01": "CN",
"ReferenceIdentification_02": "082131"
},
{
"ReferenceIdentificationQualifier_01": "CR",
"ReferenceIdentification_02": "01082131"
}
],
"DTM": [
{
"DateTimeQualifier_01": "011",
"Date_02": "200"
}
],
"N1Loop": [
{
"N1": {
"EntityIdentifierCode_01": "ST",
"Name_02": "WAL-MART DC 6094J-JIT",
"IdentificationCodeQualifier_03": "UL",
"IdentificationCode_04": "0078742035260"
}
},
{
"N1": {
"EntityIdentifierCode_01": "SF",
"Name_02": "SUPPLIER NAME"
}
}
]
},
{
"HL": {
"HierarchicalIDNumber_01": "2",
"HierarchicalParentIDNumber_02": "1",
"HierarchicalLevelCode_03": "O"
},
"PRF": {
"PurchaseOrderNumber_01": "9988776655",
"Date_04": "20051015"
},
"REF": [
{
"ReferenceIdentificationQualifier_01": "IA",
"ReferenceIdentification_02": "211555050"
},
{
"ReferenceIdentificationQualifier_01": "DP",
"ReferenceIdentification_02": "00005"
},
{
"ReferenceIdentificationQualifier_01": "MR",
"ReferenceIdentification_02": "0073"
},
{
"ReferenceIdentificationQualifier_01": "IV",
"ReferenceIdentification_02": "01140824"
}
],
"N1Loop": [
{
"N1": {
"EntityIdentifierCode_01": "BY",
"Name_02": "WAL-MART STORES,INC.",
"IdentificationCodeQualifier_03": "UL",
"IdentificationCode_04": "0078742000992"
}
}
]
},
{
"HL": {
"HierarchicalIDNumber_01": "3",
"HierarchicalParentIDNumber_02": "2",
"HierarchicalLevelCode_03": "P"
},
"MAN": [
{
"MarksandNumbersQualifier_01": "GM",
"MarksandNumbers_02": "00000010012345614785"
}
]
},
{
"HL": {
"HierarchicalIDNumber_01": "4",
"HierarchicalParentIDNumber_02": "3",
"HierarchicalLevelCode_03": "I"
},
"LIN": {
"ProductServiceIDQualifier_02": "UP",
"ProductServiceID_03": "008815509183"
},
"SN1": {
"NumberofUnitsShipped_02": "4",
"UnitorBasisforMeasurementCode_03": "EA"
}
},
{
"HL": {
"HierarchicalIDNumber_01": "5",
"HierarchicalParentIDNumber_02": "3",
"HierarchicalLevelCode_03": "I"
},
"LIN": {
"ProductServiceIDQualifier_02": "UP",
"ProductServiceID_03": "008815547321"
},
"SN1": {
"NumberofUnitsShipped_02": "9",
"UnitorBasisforMeasurementCode_03": "EA"
}
},
{
"HL": {
"HierarchicalIDNumber_01": "6",
"HierarchicalParentIDNumber_02": "1",
"HierarchicalLevelCode_03": "O"
},
"PRF": {
"PurchaseOrderNumber_01": "2288115555",
"Date_04": "20051015"
},
"REF": [
{
"ReferenceIdentificationQualifier_01": "IA",
"ReferenceIdentification_02": "211555050"
},
{
"ReferenceIdentificationQualifier_01": "DP",
"ReferenceIdentification_02": "00005"
},
{
"ReferenceIdentificationQualifier_01": "MR",
"ReferenceIdentification_02": "0073"
},
{
"ReferenceIdentificationQualifier_01": "IV",
"ReferenceIdentification_02": "01140824"
}
],
"N1Loop": [
{
"N1": {
"EntityIdentifierCode_01": "BY",
"Name_02": "WAL-MART STORES,INC.",
"IdentificationCodeQualifier_03": "UL",
"IdentificationCode_04": "0078742000015"
}
}
]
},
{
"HL": {
"HierarchicalIDNumber_01": "7",
"HierarchicalParentIDNumber_02": "6",
"HierarchicalLevelCode_03": "P"
},
"MAN": [
{
"MarksandNumbersQualifier_01": "GM",
"MarksandNumbers_02": "00000010012378945698"
}
]
},
{
"HL": {
"HierarchicalIDNumber_01": "8",
"HierarchicalParentIDNumber_02": "7",
"HierarchicalLevelCode_03": "I"
},
"LIN": {
"ProductServiceIDQualifier_02": "UP",
"ProductServiceID_03": "008815509183"
},
"SN1": {
"NumberofUnitsShipped_02": "4",
"UnitorBasisforMeasurementCode_03": "EA"
}
},
{
"HL": {
"HierarchicalIDNumber_01": "9",
"HierarchicalParentIDNumber_02": "7",
"HierarchicalLevelCode_03": "I"
},
"LIN": {
"ProductServiceIDQualifier_02": "UP",
"ProductServiceID_03": "008815547321"
},
"SN1": {
"NumberofUnitsShipped_02": "9",
"UnitorBasisforMeasurementCode_03": "EA"
}
}
],
"CTT": {
"NumberofLineItems_01": "9"
},
"SE": {
"NumberofIncludedSegments_01": "44",
"TransactionSetControlNumber_02": "0001"
}
}Parse and validate an 856 file
Read the file into typed objects with ediFabric .NET, convert it to JSON in process with the ediFabric Native bindings for Python, Java and C, or post it to the ediFabric Cloud REST API from any language.
using EdiFabric.Templates.X12004010; License.SetSerial("YOUR_SERIAL_KEY"); using (var stream = File.OpenRead(@"C:\edi\ShipNotice.txt")) using (var reader = new X12Reader(stream, "EdiFabric.Templates.X12")) { var items = await reader.ReadToEndAsync(); foreach (var transaction in items.OfType<TS856>()) { if (transaction.IsValid(out MessageErrorContext errors)) Console.WriteLine($"{transaction.ST.TransactionSetControlNumber_02} is valid"); else Console.WriteLine(string.Join(Environment.NewLine, errors.Flatten())); } }
import json import edifabric_x12 as ef serial = "YOUR_SERIAL_KEY" ef.load_library() ef.set_serial(serial) ef.set_map(json.dumps({"default": serial, "maps": {}})) edi = open("ShipNotice.txt", "rb").read() output, offset = ef.parse(edi, ef.ParseMode.JSON_VALIDATE) transactions = output[:offset] report = json.loads(output[offset:]) print(report["errors_count"])
import com.edifabric.nativex12.EdiFabricX12; import com.edifabric.nativex12.ParseMode; import com.edifabric.nativex12.ParseResult; String serial = "YOUR_SERIAL_KEY"; EdiFabricX12.loadLibrary(); EdiFabricX12.setSerial(serial); EdiFabricX12.setMap("{\"default\":\"" + serial + "\",\"maps\":{}}"); String edi = Files.readString(Path.of("ShipNotice.txt")); ParseResult result = EdiFabricX12.parse(edi, ParseMode.JSON_VALIDATE); System.out.println(result.getTransactions()); System.out.println(result.getReport());
#include "edifabric_x12.h" const char *serial = "YOUR_SERIAL_KEY"; ef_parse_result result; if (ef_load_library(NULL) != 0) return 1; ef_set_serial(serial); ef_set_map("{\"default\":\"YOUR_SERIAL_KEY\",\"maps\":{}}"); char *edi = read_file("ShipNotice.txt", NULL); /* helper in example_all_functions.c */ if (ef_parse(edi, EF_PARSE_JSON_VALIDATE, NULL, &result) == 0) { /* transactions = output[0 .. offset), report = output[offset .. length) */ fwrite(result.output.data, 1, (size_t)result.output.length, stdout); ef_free(result.output.data); }
curl -X POST 'https://api.edination.com/v2/x12/read' \ -H 'Ocp-Apim-Subscription-Key: YOUR_SERIAL_KEY' \ -H 'Content-Type: application/octet-stream' \ --data-binary '@ShipNotice.txt'
Generate an 856 file
Populate a TS856 object in .NET, or pass JSON in the shape shown above to ediFabric Native or ediFabric Cloud, and get a valid 856 file back.
using EdiFabric.Templates.X12004010; License.SetSerial("YOUR_SERIAL_KEY"); var transaction = new TS856(); // 856 is the Transaction Set Identifier Code for the Advance Ship Notice // 0001 is the Transaction Set Control Number transaction.ST = new ST(); transaction.ST.TransactionSetIdentifierCode_01 = "856"; transaction.ST.TransactionSetControlNumber_02 = "0001"; // 00 is the Transaction Set Purpose Code "00" indicates Original. // 01140824 is the Shipment Identification Number. // 20051015 is the Document Creation Date. // 1345 is the Time. // 0001 is the Hierarchical Structure. "0001" indicates "Pick and Pack Structure". transaction.BSN = new BSN(); transaction.BSN.TransactionSetPurposeCode_01 = "00"; transaction.BSN.ShipmentIdentification_02 = "01140824"; transaction.BSN.Date_03 = "20051015"; transaction.BSN.Time_04 = "1345"; transaction.BSN.HierarchicalStructureCode_05 = "0001"; // Repeating HL Loops transaction.HLLoop = new List<Loop_HL_856>(); // ... 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 X12Writer(stream)) { writer.Write(SegmentBuilders.BuildIsa("1")); writer.Write(SegmentBuilders.BuildGs("1")); writer.Write(transaction); } Console.WriteLine(Encoding.UTF8.GetString(stream.ToArray())); }
import json import edifabric_x12 as ef serial = "YOUR_SERIAL_KEY" ef.load_library() ef.set_serial(serial) ef.set_map(json.dumps({"default": serial, "maps": {}})) # the transactions JSON returned by ef.parse, edited or produced by your application transactions = open("ShipNotice.json", "rb").read() edi = ef.build(transactions, postfix="\r\n") print(edi)
import com.edifabric.nativex12.EdiFabricX12; String serial = "YOUR_SERIAL_KEY"; EdiFabricX12.loadLibrary(); EdiFabricX12.setSerial(serial); EdiFabricX12.setMap("{\"default\":\"" + serial + "\",\"maps\":{}}"); // the transactions JSON returned by parse, edited or produced by your application String transactions = Files.readString(Path.of("ShipNotice.json")); String edi = EdiFabricX12.build(transactions, "\r\n"); System.out.println(edi);
#include "edifabric_x12.h" ef_buffer edi; if (ef_load_library(NULL) != 0) return 1; ef_set_serial("YOUR_SERIAL_KEY"); ef_set_map("{\"default\":\"YOUR_SERIAL_KEY\",\"maps\":{}}"); /* the transactions JSON returned by ef_parse, edited or produced by your application */ char *transactions = read_file("ShipNotice.json", NULL); if (ef_build(transactions, "\r\n", &edi) == 0) { fwrite(edi.data, 1, (size_t)edi.length, stdout); ef_free(edi.data); }
# the JSON returned by /read, edited or produced by your application curl -X POST 'https://api.edination.com/v2/x12/write' \ -H 'Ocp-Apim-Subscription-Key: YOUR_SERIAL_KEY' \ -H 'Content-Type: application/json' \ --data-binary '@ShipNotice.json' \ -o 'ShipNotice.txt'
Complete ediFabric .NET example
A complete C# program for the X12 856, built on TS856 in EdiFabric.Templates.X12. The same code is in the ediFabric .NET examples on GitHub.
using EdiFabric.Core.Model.Edi;
using EdiFabric.Core.Model.Edi.X12;
using EdiFabric.Examples.X12.Common;
using EdiFabric.Framework.Readers;
using EdiFabric.Framework.Writers;
using EdiFabric.Templates.X12004010;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace EdiFabric.Examples.X12.T856
{
class Program
{
static void Main(string[] args)
{
SerialKey.Set(Common.SerialKey.Get());
Read();
Write();
}
///
/// Read Ship Notice
///
static void Read()
{
var ediStream = File.OpenRead(Directory.GetCurrentDirectory() + @"\..\..\..\Files\X12\ShipNotice.txt");
List ediItems;
using (var ediReader = new X12Reader(ediStream, "EdiFabric.Templates.X12"))
ediItems = ediReader.ReadToEnd().ToList();
var transactions = ediItems.OfType();
foreach (var transaction in transactions)
{
if (transaction.HasErrors)
{
// partially parsed
var errors = transaction.ErrorContext.Flatten();
}
}
}
///
/// Write Ship Notice
///
static void Write()
{
var transaction = BuildShipNotice("1");
using (var stream = new MemoryStream())
{
using (var writer = new X12Writer(stream))
{
writer.Write(SegmentBuilders.BuildIsa("1"));
writer.Write(SegmentBuilders.BuildGs("1"));
writer.Write(transaction);
}
var ediString = stream.LoadToString();
}
}
///
/// Builds ship notice.
/// Original from http://www.jobisez.com/edi/tp/guide.aspx?doc=/edi-igs/Walmart/856ASNDSDC5010.pdf
///
static TS856 BuildShipNotice(string controlNumber)
{
var result = new TS856();
// 856 is the Transaction Set Identifier Code for the Advance Ship Notice
// 0001 is the Transaction Set Control Number
result.ST = new ST();
result.ST.TransactionSetIdentifierCode_01 = "856";
result.ST.TransactionSetControlNumber_02 = controlNumber.PadLeft(9, '0');
// 00 is the Transaction Set Purpose Code "00" indicates Original.
// 01140824 is the Shipment Identification Number.
// 20051015 is the Document Creation Date.
// 1345 is the Time.
// 0001 is the Hierarchical Structure. "0001" indicates "Pick and Pack Structure".
result.BSN = new BSN();
result.BSN.TransactionSetPurposeCode_01 = "00";
result.BSN.ShipmentIdentification_02 = "01140824";
result.BSN.Date_03 = "20051015";
result.BSN.Time_04 = "1345";
result.BSN.HierarchicalStructureCode_05 = "0001";
// Repeating HL Loops
result.HLLoop = new List();
// Begin HL Loop 1
var hlLoop1 = new Loop_HL_856();
// 1 is Hierarchical ID Number.
// S is the Hierarchical Level Code. “S” indicates "Shipment".
// This HL is the first HL used, and has no parent to identify.
hlLoop1.HL = new HL();
hlLoop1.HL.HierarchicalIDNumber_01 = "1";
hlLoop1.HL.HierarchicalLevelCode_03 = "S";
// Repeating TD1
hlLoop1.TD1 = new List();
// CTN25 is Packaging Code. “CTN” indicates “Carton”, and “25” indicates “Corrugated or Solid”.
// 2 is the Lading Quantity.
// G is the Weight Qualifier. “G” indicates "Gross Weight".
// 45582 is the Weight (Gross).
// LB is the Unit or Basis for Measurement Code. “LB” indicates “Pound”.
// 1000 is the Volume (Gross).
// CF is the Unit or Basis for Measurement Code. “CF” indicates “Cubic Feet”.
var td11 = new TD1();
td11.PackagingCode_01 = "CTN25";
td11.LadingQuantity_02 = "2";
td11.WeightQualifier_06 = "G";
td11.Weight_07 = "45582";
td11.UnitorBasisforMeasurementCode_08 = "LB";
td11.Volume_09 = "1000";
td11.UnitorBasisforMeasurementCode_10 = "CF";
hlLoop1.TD1.Add(td11);
// Repeating TD5
hlLoop1.TD5 = new List();
// B is the Routing Sequence Code. “B” indicates "Origin/Delivery Carrier (Any Mode)".
// 2 is the Identification Code Qualifier. “2” indicates “Standard Carrier Alpha Code(SCAC)”.
// JBHT is the Identification Code(SCAC).Indicates the carrier JB Hunt.
// M is the Transportation Method / Type Code. “M” indicates “Motor(Common Carrier)”.
var td51 = new TD5();
td51.RoutingSequenceCode_01 = "B";
td51.IdentificationCodeQualifier_02 = "2";
td51.IdentificationCode_03 = "JBHT";
td51.TransportationMethodTypeCode_04 = "M";
hlLoop1.TD5.Add(td51);
// Repeating TD3
hlLoop1.TD3 = new List();
// TL is the Equipment Description Code. “TL” indicates Trailer.
// ABCD is the Equipment Initial
// 07213567 is the Equipment Number
// 30394938483234 is the Seal Number.This is a unique number on seal used to close a shipment.
var td31 = new TD3();
td31.EquipmentDescriptionCode_01 = "TL";
td31.EquipmentInitial_02 = "ABCD";
td31.EquipmentNumber_03 = "07213567";
td31.SealNumber_09 = "30394938483234";
hlLoop1.TD3.Add(td31);
// Repeating REF
hlLoop1.REF = new List();
// BM is the Reference Identification Qualifier. “BM” indicates “Bill of Lading Number”.
// 01140824 is the Reference Identification
var ref1 = new REF();
ref1.ReferenceIdentificationQualifier_01 = "BM";
ref1.ReferenceIdentification_02 = "01140824";
hlLoop1.REF.Add(ref1);
// CN is the Reference Identification Qualifier “CN” indicates the Carrier PRO Tracking Number.
// 082131 is the Reference Identification
var ref2 = new REF();
ref2.ReferenceIdentificationQualifier_01 = "CN";
ref2.ReferenceIdentification_02 = "082131";
hlLoop1.REF.Add(ref2);
// CR is the Reference Identification Qualifier “CR” indicates the Customer Reference Number(Wal - Mart Load Number).
// 01082131 is the Reference Identification
var ref3 = new REF();
ref3.ReferenceIdentificationQualifier_01 = "CR";
ref3.ReferenceIdentification_02 = "01082131";
hlLoop1.REF.Add(ref3);
// Repeating DTM
hlLoop1.DTM = new List();
// 011 is the Date/Time Qualifier “011” indicates the “Date Shipped”
// 20051015 is the Date (Shipped)
var dtm1 = new DTM();
dtm1.DateTimeQualifier_01 = "011";
dtm1.Date_02 = "200";
hlLoop1.DTM.Add(dtm1);
// Repeating N1 Loops
hlLoop1.N1Loop = new List();
// Begin N1 Loop 1
var n1Loop1 = new Loop_N1_856();
// ST is the Entity Identifier Code. “ST” indicates “Ship To”.
// WAL - MART DC 6094J - JIT is the Name (Ship To).
// UL is the Identification Code Qualifier. “UL” indicates
// “Global Location Number(GLN)”.
// 0078742035260 is the Identification Code(GLN).
n1Loop1.N1 = new N1();
n1Loop1.N1.EntityIdentifierCode_01 = "ST";
n1Loop1.N1.Name_02 = "WAL-MART DC 6094J-JIT";
n1Loop1.N1.IdentificationCodeQualifier_03 = "UL";
n1Loop1.N1.IdentificationCode_04 = "0078742035260";
// End N1 Loop 1
hlLoop1.N1Loop.Add(n1Loop1);
// Begin N1 Loop 2
var n1Loop2 = new Loop_N1_856();
// SF is the Entity Identifier Code (Ship From)
// SUPPLIER NAME is the Name.
n1Loop2.N1 = new N1();
n1Loop2.N1.EntityIdentifierCode_01 = "SF";
n1Loop2.N1.Name_02 = "SUPPLIER NAME";
// End N1 Loop 2
hlLoop1.N1Loop.Add(n1Loop2);
// End HL Loop 1
result.HLLoop.Add(hlLoop1);
// Begin HL Loop 2
var hlLoop2 = new Loop_HL_856();
// 2 is the Hierarchical ID Number.
// 1 is the Hierarchical Parent ID Number. (Shipment)
// O is the Hierarchical Level Code. “O” indicates “Order”
hlLoop2.HL = new HL();
hlLoop2.HL.HierarchicalIDNumber_01 = "2";
hlLoop2.HL.HierarchicalParentIDNumber_02 = "1";
hlLoop2.HL.HierarchicalLevelCode_03 = "O";
// 9988776655 the Purchase Order Number.
// 20051015 is the Date (Purchase Order Date).
hlLoop2.PRF = new PRF();
hlLoop2.PRF.PurchaseOrderNumber_01 = "9988776655";
hlLoop2.PRF.Date_04 = "20051015";
// Repeating REF
hlLoop2.REF = new List();
// IA is the Reference Identification Qualifier. “IA” indicates
// “Internal Vendor Number”.
// 211555050 is the Reference Identification
var ref4 = new REF();
ref4.ReferenceIdentificationQualifier_01 = "IA";
ref4.ReferenceIdentification_02 = "211555050";
hlLoop2.REF.Add(ref4);
// DP is the Reference Identification Qualifier. “DP” indicates
// “Department Number”.
// 00005 is the Reference Identification(Wal - Mart Department
// Number).
var ref5 = new REF();
ref5.ReferenceIdentificationQualifier_01 = "DP";
ref5.ReferenceIdentification_02 = "00005";
hlLoop2.REF.Add(ref5);
// MR is the Reference Identification Qualifier. “MR” indicates
// “Merchandise Type Code”.
// 0073 is the Reference Identification
var ref6 = new REF();
ref6.ReferenceIdentificationQualifier_01 = "MR";
ref6.ReferenceIdentification_02 = "0073";
hlLoop2.REF.Add(ref6);
// IV is the Reference Identification Qualifier. “IV” indicates
// “Seller’s Invoice Number”.
// 01140824 is the Reference Identification
var ref7 = new REF();
ref7.ReferenceIdentificationQualifier_01 = "IV";
ref7.ReferenceIdentification_02 = "01140824";
hlLoop2.REF.Add(ref7);
// Repeating N1 Loops
hlLoop2.N1Loop = new List();
// Begin N1 Loop 1
var n1Loop3 = new Loop_N1_856();
// BY is the Entity Identifier Code. “BY” indicates “Buying
// Party(Purchaser)”.
// WAL - MART STORES, INC. is the Name.
// UL is the Identification Code Qualifier. “UL” indicates
// “Global Location Number(GLN)”.
// 0078742000992 is the Identification Code(GLN).
n1Loop3.N1 = new N1();
n1Loop3.N1.EntityIdentifierCode_01 = "BY";
n1Loop3.N1.Name_02 = "WAL-MART STORES,INC.";
n1Loop3.N1.IdentificationCodeQualifier_03 = "UL";
n1Loop3.N1.IdentificationCode_04 = "0078742000992";
// End N1 Loop 1
hlLoop2.N1Loop.Add(n1Loop3);
// End HL Loop 2
result.HLLoop.Add(hlLoop2);
// Begin HL Loop 3
var hlLoop3 = new Loop_HL_856();
// 3 is the Hierarchical ID Number.
// 2 is the Hierarchical Parent ID Number. (Order)
// P is the Hierarchical Level Code. “P” indicates “Pack”.
hlLoop3.HL = new HL();
hlLoop3.HL.HierarchicalIDNumber_01 = "3";
hlLoop3.HL.HierarchicalParentIDNumber_02 = "2";
hlLoop3.HL.HierarchicalLevelCode_03 = "P";
// Repeating MAN
hlLoop3.MAN = new List();
// GM is the Marks and Numbers Qualifier. “GM” indicates
// “EAN.UCC Serial Shipping Container Code(SSCC) and
// Application Identifier.”
// 00000010012345614785 is the Marks and Numbers(SCC-18).
var man1 = new MAN();
man1.MarksandNumbersQualifier_01 = "GM";
man1.MarksandNumbers_02 = "00000010012345614785";
hlLoop3.MAN.Add(man1);
// End HL Loop 3
result.HLLoop.Add(hlLoop3);
// Begin HL Loop 4
var hlLoop4 = new Loop_HL_856();
// 4 is the Hierarchical ID Number.
// 3 is the Hierarchical Parent ID Number. (Pack)
// I is the Hierarchical Level Code. “I” indicates “Item”
hlLoop4.HL = new HL();
hlLoop4.HL.HierarchicalIDNumber_01 = "4";
hlLoop4.HL.HierarchicalParentIDNumber_02 = "3";
hlLoop4.HL.HierarchicalLevelCode_03 = "I";
// UP is the Product/Service ID Qualifier. “UP” indicates “UCC12"
// 008815509183 is the Product / Service ID
hlLoop4.LIN = new LIN();
hlLoop4.LIN.ProductServiceIDQualifier_02 = "UP";
hlLoop4.LIN.ProductServiceID_03 = "008815509183";
// 4 is the Number of Units Shipped.
// EA is the Unit or Basis for Measurement Code. “EA” indicates
// “Each”.
hlLoop4.SN1 = new SN1();
hlLoop4.SN1.NumberofUnitsShipped_02 = "4";
hlLoop4.SN1.UnitorBasisforMeasurementCode_03 = "EA";
// End HL Loop 4
result.HLLoop.Add(hlLoop4);
// Begin HL Loop 5
var hlLoop5 = new Loop_HL_856();
// 5 is the Hierarchical ID Number.
// 3 is the Hierarchical Parent ID Number. (Pack)
// I is the Hierarchical Level Code. “I” indicates “Item”.
hlLoop5.HL = new HL();
hlLoop5.HL.HierarchicalIDNumber_01 = "5";
hlLoop5.HL.HierarchicalParentIDNumber_02 = "3";
hlLoop5.HL.HierarchicalLevelCode_03 = "I";
// UP is the Product/Service ID Qualifier. “UP” indicates “UCC
// -12”.
// 008815547321 is the Product / Service ID.
hlLoop5.LIN = new LIN();
hlLoop5.LIN.ProductServiceIDQualifier_02 = "UP";
hlLoop5.LIN.ProductServiceID_03 = "008815547321";
// 9 is the Number of Units Shipped.
// EA is the Unit or Basis for Measurement Code. “EA”
// indicates “Each”.
hlLoop5.SN1 = new SN1();
hlLoop5.SN1.NumberofUnitsShipped_02 = "9";
hlLoop5.SN1.UnitorBasisforMeasurementCode_03 = "EA";
// End HL Loop 5
result.HLLoop.Add(hlLoop5);
// Begin HL Loop 6
var hlLoop6 = new Loop_HL_856();
// 6 is the Hierarchical ID Number.
// 1 is the Hierarchical Parent ID Number. (Shipment)
// O is the Hierarchical Level Code. “O” indicates “Order”.
hlLoop6.HL = new HL();
hlLoop6.HL.HierarchicalIDNumber_01 = "6";
hlLoop6.HL.HierarchicalParentIDNumber_02 = "1";
hlLoop6.HL.HierarchicalLevelCode_03 = "O";
// 2288115555 the Purchase Order Number.
// 20051015 is the Date (Purchase Order Date).
hlLoop6.PRF = new PRF();
hlLoop6.PRF.PurchaseOrderNumber_01 = "2288115555";
hlLoop6.PRF.Date_04 = "20051015";
// Repeating REF
hlLoop6.REF = new List();
// IA is the Reference Identification Qualifier. “IA” indicates
// “Internal Vendor Number”.
// 211555050 is the Reference Identification
var ref8 = new REF();
ref8.ReferenceIdentificationQualifier_01 = "IA";
ref8.ReferenceIdentification_02 = "211555050";
hlLoop6.REF.Add(ref8);
// DP is the Reference Identification Qualifier. “DP” indicates
// “Department Number”.
// 00005 is the Reference Identification(Wal - Mart Department
// Number).
var ref9 = new REF();
ref9.ReferenceIdentificationQualifier_01 = "DP";
ref9.ReferenceIdentification_02 = "00005";
hlLoop6.REF.Add(ref9);
// MR is the Reference Identification Qualifier. “MR” indicates
// “Merchandise Type Code”.
// 0073 is the Reference Identification
var ref10 = new REF();
ref10.ReferenceIdentificationQualifier_01 = "MR";
ref10.ReferenceIdentification_02 = "0073";
hlLoop6.REF.Add(ref10);
// IV is the Reference Identification Qualifier. “IV” indicates
// “Seller’s Invoice Number”.
// 01140824 is the Reference Identification
var ref11 = new REF();
ref11.ReferenceIdentificationQualifier_01 = "IV";
ref11.ReferenceIdentification_02 = "01140824";
hlLoop6.REF.Add(ref11);
// Repeating N1 Loops
hlLoop6.N1Loop = new List();
// Begin N1 Loop 1
var n1Loop4 = new Loop_N1_856();
// BY is the Entity Identifier Code. “BY” indicates “Buying
// Party(Purchaser)”.
// WAL - MART STORES, INC. is the Name.
// UL is the Identification Code Qualifier. “UL” indicates
// “Global Location Number(GLN)”.
// 0078742000015 is the Identification Code(GLN).
n1Loop4.N1 = new N1();
n1Loop4.N1.EntityIdentifierCode_01 = "BY";
n1Loop4.N1.Name_02 = "WAL-MART STORES,INC.";
n1Loop4.N1.IdentificationCodeQualifier_03 = "UL";
n1Loop4.N1.IdentificationCode_04 = "0078742000015";
// End N1 Loop 1
hlLoop6.N1Loop.Add(n1Loop4);
// End HL Loop 6
result.HLLoop.Add(hlLoop6);
// Begin HL Loop 7
var hlLoop7 = new Loop_HL_856();
// 7 is the Hierarchical ID Number.
// 6 is the Hierarchical Parent ID Number. (Order)
// P is the Hierarchical Level Code. “P” indicates “Pack”.
hlLoop7.HL = new HL();
hlLoop7.HL.HierarchicalIDNumber_01 = "7";
hlLoop7.HL.HierarchicalParentIDNumber_02 = "6";
hlLoop7.HL.HierarchicalLevelCode_03 = "P";
// Repeating MAN
hlLoop7.MAN = new List();
// GM is the Marks and Numbers Qualifier. “GM” indicates
// “EAN.UCC Serial Shipping Container Code(SSCC) and
// Application Identifier”.
// 00000010012378945698 is the Marks and Numbers(SCC-14).
var man2 = new MAN();
man2.MarksandNumbersQualifier_01 = "GM";
man2.MarksandNumbers_02 = "00000010012378945698";
hlLoop7.MAN.Add(man2);
// End HL Loop 7
result.HLLoop.Add(hlLoop7);
// Begin HL Loop 8
var hlLoop8 = new Loop_HL_856();
// 8 is the Hierarchical ID Number.
// 7 is the Hierarchical Parent ID Number. (Pack)
// I is the Hierarchical Level Code. “I” indicates “Item”
hlLoop8.HL = new HL();
hlLoop8.HL.HierarchicalIDNumber_01 = "8";
hlLoop8.HL.HierarchicalParentIDNumber_02 = "7";
hlLoop8.HL.HierarchicalLevelCode_03 = "I";
// UP is the Product/Service ID Qualifier. “UP” indicates “UCC
// -12”.
// 008815509183 is the Product / Service ID.
hlLoop8.LIN = new LIN();
hlLoop8.LIN.ProductServiceIDQualifier_02 = "UP";
hlLoop8.LIN.ProductServiceID_03 = "008815509183";
// 4 is the Number of Units Shipped.
// EA is the Unit or Basis for Measurement Code. “EA”
// indicates “Each”.
hlLoop8.SN1 = new SN1();
hlLoop8.SN1.NumberofUnitsShipped_02 = "4";
hlLoop8.SN1.UnitorBasisforMeasurementCode_03 = "EA";
// End HL Loop 8
result.HLLoop.Add(hlLoop8);
// Begin HL Loop 9
var hlLoop9 = new Loop_HL_856();
// 9 is the Hierarchical ID Number.
// 7 is the Hierarchical Parent ID Number. (Pack)
// I is the Hierarchical Level Code. “I” indicates “Item”.
hlLoop9.HL = new HL();
hlLoop9.HL.HierarchicalIDNumber_01 = "9";
hlLoop9.HL.HierarchicalParentIDNumber_02 = "7";
hlLoop9.HL.HierarchicalLevelCode_03 = "I";
// UP is the Product/Service ID Qualifier. “UP” indicates “UCC
// -12”.
// 008815547321 is the Product / Service ID.
hlLoop9.LIN = new LIN();
hlLoop9.LIN.ProductServiceIDQualifier_02 = "UP";
hlLoop9.LIN.ProductServiceID_03 = "008815547321";
// 9 is the Number of Units Shipped.
// EA is the Unit or Basis for Measurement Code. “EA”
// indicates “Each”.
hlLoop9.SN1 = new SN1();
hlLoop9.SN1.NumberofUnitsShipped_02 = "9";
hlLoop9.SN1.UnitorBasisforMeasurementCode_03 = "EA";
// End HL Loop 9
result.HLLoop.Add(hlLoop9);
// 9 is the Number of Line Items (number of HL segments in the
// document).
result.CTT = new CTT();
result.CTT.NumberofLineItems_01 = "9";
return result;
}
}
}More operations in ediFabric .NET
856 questions
What is the HL structure of an 856?
HL03 gives each level: S shipment, O order, T tare, P pack, I item. Retailers usually require either S-O-P-I (pick and pack) or S-O-T-P-I with pallets.
When should the 856 be sent?
After the goods leave and before they arrive. Most retailers require it within a set time of shipment and charge back late or inaccurate ASNs.
What is the EDIFACT equivalent?
DESADV, the despatch advice message.
How do I parse and generate X12 856 files in .NET, Python, Java and C?
In .NET, install EdiFabric and EdiFabric.Templates.X12, read the file with X12Reader into TS856 objects and write them back with X12Writer. From Python, Java or C, use ediFabric Native, which converts 856 files to JSON and JSON back to X12 inside your process. From any other language, post the file to the ediFabric Cloud REST API.
Resources
Parse your first X12 856 in five minutes
The Community plan is free forever and needs no credit card. It includes ediFabric .NET, Native and Cloud with one serial key.
Sign up free Validate EDI files free