X12 857 Shipment and Billing Notice Last updated: 2026-09-29

The 857 is the X12 shipment and billing notice. It combines the ship notice and the invoice in one transaction, so a supplier can announce a shipment and bill for it at the same time.

BHT starts the transaction and HL loops carry the shipment, order and item levels with both shipping and billing information.

At a glance

Standard
X12
Version
004010
Functional group
BS (GS01)
Sent by
Supplier to buyer
Responses
997
ediFabric .NET template
TS857 in EdiFabric.Templates.X12
OpenEDI definition
View 857 in the spec library

857 structure

The full X12 857 layout from its OpenEDI definition, the same model ediFabric uses to parse, validate and generate it: 16 loops and 67 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
STTransaction Set HeaderMandatory1
BHTBeginning of Hierarchical TransactionMandatory1
HL loopHierarchical LevelMandatory>1
HLHierarchical LevelMandatory1
G05 loopTotal Shipment InformationOptional1
G05Total Shipment InformationMandatory1
TD1Carrier Details (Quantity and Weight)Optional5
TD3Carrier Details (Equipment)Optional5
TD4Carrier Details (Special Handling, or Hazardous Materials, or Both)Optional5
TD5Carrier Details (Routing Sequence/Transit Time)Optional10
FOBF.O.B. Related InstructionsOptional1
DTMDate/Time ReferenceOptional5
N9Reference IdentificationOptional20
PERAdministrative Communications ContactOptional5
CURCurrencyOptional1
N1 loopNameOptional10
N1NameMandatory1
N2Additional Name InformationOptional2
N3Address InformationOptional2
N4Geographic LocationOptional1
LM loopCode Source InformationOptional>1
LMCode Source InformationMandatory1
LQIndustry CodeMandatory>1
TDS loopTotal Monetary Value SummaryOptional1
TDSTotal Monetary Value SummaryMandatory1
PRFPurchase Order ReferenceOptional1
N9Reference IdentificationOptional>1
DTMDate/Time ReferenceOptional10
ITDTerms of Sale/Deferred Terms of SaleOptional5
TXITax InformationOptional10
SN1Item Detail (Shipment)Optional1
ISSInvoice Shipment SummaryOptional1
SAC loopService, Promotion, Allowance, or Charge InformationOptional25
SACService, Promotion, Allowance, or Charge InformationMandatory1
TXITax InformationOptional10
N1 loopNameOptional10
N1NameMandatory1
N2Additional Name InformationOptional2
N3Address InformationOptional2
N4Geographic LocationOptional1
FA1 loopType of Financial Accounting DataOptional>1
FA1Type of Financial Accounting DataMandatory1
FA2Accounting DataMandatory>1
PAL loopPallet InformationOptional1
PALPallet InformationMandatory1
SN1Item Detail (Shipment)Optional1
MANMarks and NumbersOptional10
LX loopAssigned NumberOptional1
LXAssigned NumberMandatory1
N9Reference IdentificationOptional15
SN1Item Detail (Shipment)Optional1
PO4Item Physical DetailsOptional1
MEAMeasurementsOptional10
PKGMarking, Packaging, LoadingOptional10
MANMarks and NumbersOptional10
IT1 loopBaseline Item Data (Invoice)Optional1
IT1Baseline Item Data (Invoice)Mandatory1
IT3Additional Item DataOptional1
PO4Item Physical DetailsOptional1
TD4Carrier Details (Special Handling, or Hazardous Materials, or Both)Optional>1
TC2CommodityOptional5
TXITax InformationOptional10
CTPPricing InformationOptional10
N9Reference IdentificationOptional10
MEAMeasurementsOptional10
DTMDate/Time ReferenceOptional10
ITDTerms of Sale/Deferred Terms of SaleOptional>1
PID loopProduct/Item DescriptionOptional25
PIDProduct/Item DescriptionMandatory1
MEAMeasurementsOptional10
SLN loopSubline Item DetailOptional1000
SLNSubline Item DetailMandatory1
PIDProduct/Item DescriptionOptional25
SAC loopService, Promotion, Allowance, or Charge InformationOptional25
SACService, Promotion, Allowance, or Charge InformationMandatory1
TXITax InformationOptional10
LM loopCode Source InformationOptional>1
LMCode Source InformationMandatory1
LQIndustry CodeMandatory>1
FA1 loopType of Financial Accounting DataOptional>1
FA1Type of Financial Accounting DataMandatory1
FA2Accounting DataMandatory>1
SETransaction Set TrailerMandatory1

Sample 857 file

A shipment and billing notice with its HL hierarchy. 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*857*000012103~
BHT*0001*00**980110~
HL*1**S~
G05*3*UN~
DTM*011*980110***19~
N1*SF**15*216793X~
N1*ST**15*6678157~
N1*BT**15*1135309~
N1*VN**15*2002450~
HL*2**O~
TDS*383750*383750*218736~
PRF*0123456789123**980106~
HL*3**P~
LX*1~
MAN*GM*00097800006400000012~
HL*4**I~
IT1*1*2*UN*8.4*PE*IB*0835201031~
CTP**SLP*10.5***DIS*.8~
HL*5**I~
IT1*2*1*UN*24*PE*IB*0835208338~
CTP**SLP*30***DIS*.8~
SE*21*000012103~
GE*2*000000001~
IEA*1*000000263~

The same 857 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": "857",
    "TransactionSetControlNumber_02": "000012103"
  },
  "BHT": {
    "HierarchicalStructureCode_01": "0001",
    "TransactionSetPurposeCode_02": "00",
    "Date_04": "980110"
  },
  "HLLoop": [
    {
      "HL": {
        "HierarchicalIDNumber_01": "1",
        "HierarchicalLevelCode_03": "S"
      },
      "G05Loop": {
        "G05": {
          "NumberofUnitsShipped_01": "3",
          "UnitorBasisforMeasurementCode_02": "UN"
        },
        "DTM": [
          {
            "DateTimeQualifier_01": "011",
            "Date_02": "980110",
            "DateTimePeriodFormatQualifier_05": "19"
          }
        ],
        "N1Loop": [
          {
            "N1": {
              "EntityIdentifierCode_01": "SF",
              "IdentificationCodeQualifier_03": "15",
              "IdentificationCode_04": "216793X"
            }
          },
          {
            "N1": {
              "EntityIdentifierCode_01": "ST",
              "IdentificationCodeQualifier_03": "15",
              "IdentificationCode_04": "6678157"
            }
          },
          {
            "N1": {
              "EntityIdentifierCode_01": "BT",
              "IdentificationCodeQualifier_03": "15",
              "IdentificationCode_04": "1135309"
            }
          },
          {
            "N1": {
              "EntityIdentifierCode_01": "VN",
              "IdentificationCodeQualifier_03": "15",
              "IdentificationCode_04": "2002450"
            }
          }
        ]
      }
    },
    {
      "HL": {
        "HierarchicalIDNumber_01": "2",
        "HierarchicalLevelCode_03": "O"
      },
      "TDSLoop": {
        "TDS": {
          "Amount_01": "383750",
          "Amount_02": "383750",
          "Amount_03": "218736"
        },
        "PRF": {
          "PurchaseOrderNumber_01": "0123456789123",
          "ChangeOrderSequenceNumber_03": "980106"
        }
      }
    },
    {
      "HL": {
        "HierarchicalIDNumber_01": "3",
        "HierarchicalLevelCode_03": "P"
      },
      "LXLoop": {
        "LX": {
          "AssignedNumber_01": "1"
        },
        "MAN": [
          {
            "MarksandNumbersQualifier_01": "GM",
            "MarksandNumbers_02": "00097800006400000012"
          }
        ]
      }
    },
    {
      "HL": {
        "HierarchicalIDNumber_01": "4",
        "HierarchicalLevelCode_03": "I"
      },
      "IT1Loop": {
        "IT1": {
          "AssignedIdentification_01": "1",
          "QuantityInvoiced_02": "2",
          "UnitorBasisforMeasurementCode_03": "UN",
          "UnitPrice_04": "8.4",
          "BasisofUnitPriceCode_05": "PE",
          "ProductServiceIDQualifier_06": "IB",
          "ProductServiceID_07": "0835201031"
        },
        "CTP": [
          {
            "PriceIdentifierCode_02": "SLP",
            "UnitPrice_03": "10.5",
            "PriceMultiplierQualifier_06": "DIS",
            "Multiplier_07": ".8"
          }
        ]
      }
    },
    {
      "HL": {
        "HierarchicalIDNumber_01": "5",
        "HierarchicalLevelCode_03": "I"
      },
      "IT1Loop": {
        "IT1": {
          "AssignedIdentification_01": "2",
          "QuantityInvoiced_02": "1",
          "UnitorBasisforMeasurementCode_03": "UN",
          "UnitPrice_04": "24",
          "BasisofUnitPriceCode_05": "PE",
          "ProductServiceIDQualifier_06": "IB",
          "ProductServiceID_07": "0835208338"
        },
        "CTP": [
          {
            "PriceIdentifierCode_02": "SLP",
            "UnitPrice_03": "30",
            "PriceMultiplierQualifier_06": "DIS",
            "Multiplier_07": ".8"
          }
        ]
      }
    }
  ],
  "SE": {
    "NumberofIncludedSegments_01": "21",
    "TransactionSetControlNumber_02": "000012103"
  }
}

Parse and validate an 857 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\ShipBillNotice.txt"))
using (var reader = new X12Reader(stream, "EdiFabric.Templates.X12"))
{
    var items = await reader.ReadToEndAsync();
    foreach (var transaction in items.OfType<TS857>())
    {
        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("ShipBillNotice.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("ShipBillNotice.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("ShipBillNotice.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 '@ShipBillNotice.txt'

Generate an 857 file

Populate a TS857 object in .NET, or pass JSON in the shape shown above to ediFabric Native or ediFabric Cloud, and get a valid 857 file back.

using EdiFabric.Templates.X12004010;

License.SetSerial("YOUR_SERIAL_KEY");

var transaction = new TS857();

//  Transaction 857 
//  Set control number 12103
transaction.ST = new ST();
transaction.ST.TransactionSetIdentifierCode_01 = "857";
transaction.ST.TransactionSetControlNumber_02 = "0001";

//  Hierarchical structure code 0001 
//  Original transaction set
//  Ship date of 01 / 10 / 98
transaction.BHT = new BHT();
transaction.BHT.HierarchicalStructureCode_01 = "0001";
transaction.BHT.TransactionSetPurposeCode_02 = "00";
transaction.BHT.Date_04 = "980110";

//  Repeating HL Loops
transaction.HLLoop = new List<Loop_HL_857>();

//  Begin HL Loop 1
var hlLoop1 = new Loop_HL_857();

// ... 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("ShipBillNotice.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("ShipBillNotice.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("ShipBillNotice.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 '@ShipBillNotice.json' \
-o 'ShipBillNotice.txt'

Complete ediFabric .NET example

A complete C# program for the X12 857, built on TS857 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.T857
{
    class Program
    {
        static void Main(string[] args)
        {
            SerialKey.Set(Common.SerialKey.Get());
            Read();
            Write();
        }

        ///
        /// Read Ship Bill Notice
        ///
        static void Read()
        {
            var ediStream = File.OpenRead(Directory.GetCurrentDirectory() + @"\..\..\..\Files\X12\ShipBillNotice.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 Bill Notice
        ///
        static void Write()
        {
            var transaction = BuildShipBillNotice("000012103");

            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 bill notice.
        /// Original from http://www.bergware.net/bisacwww/857_3060.htm
        ///
        static TS857 BuildShipBillNotice(string controlNumber)
        {
            var result = new TS857();

            //  Transaction 857
            //  Set control number 12103
            result.ST = new ST();
            result.ST.TransactionSetIdentifierCode_01 = "857";
            result.ST.TransactionSetControlNumber_02 = controlNumber.PadLeft(9, '0');

            //  Hierarchical structure code 0001
            //  Original transaction set
            //  Ship date of 01 / 10 / 98
            result.BHT = new BHT();
            result.BHT.HierarchicalStructureCode_01 = "0001";
            result.BHT.TransactionSetPurposeCode_02 = "00";
            result.BHT.Date_04 = "980110";

            //  Repeating HL Loops
            result.HLLoop = new List();

            //  Begin HL Loop 1
            var hlLoop1 = new Loop_HL_857();

            //  Hierarchical level 1 shipment
            hlLoop1.HL = new HL();
            hlLoop1.HL.HierarchicalIDNumber_01 = "1";
            hlLoop1.HL.HierarchicalLevelCode_03 = "S";

            //  Begin G05 Loop 1
            hlLoop1.G05Loop = new Loop_G05_857();

            //  3 shipped units
            hlLoop1.G05Loop.G05 = new G05();
            hlLoop1.G05Loop.G05.NumberofUnitsShipped_01 = "3";
            hlLoop1.G05Loop.G05.UnitorBasisforMeasurementCode_02 = "UN";

            //  Repeating DTM
            hlLoop1.G05Loop.DTM = new List();

            //  Ship date of
            //  01 / 10 / 98
            //  Century designation of 19
            var dtm1 = new DTM();
            dtm1.DateTimeQualifier_01 = "011";
            dtm1.Date_02 = "980110";
            dtm1.DateTimePeriodFormatQualifier_05 = "19";
            hlLoop1.G05Loop.DTM.Add(dtm1);

            //  Repeating N1 G05 Loops
            hlLoop1.G05Loop.N1Loop = new List();

            //  Begin N1 G05 Loop 1
            var n1Loop1 = new Loop_N1_857();

            //  Ship from
            //  SAN
            //  216793X
            n1Loop1.N1 = new N1();
            n1Loop1.N1.EntityIdentifierCode_01 = "SF";
            n1Loop1.N1.IdentificationCodeQualifier_03 = "15";
            n1Loop1.N1.IdentificationCode_04 = "216793X";

            //  End N1 G05 Loop 1
            hlLoop1.G05Loop.N1Loop.Add(n1Loop1);

            //  Begin N1 G05 Loop 2
            var n1Loop2 = new Loop_N1_857();

            //  Ship to
            //  SAN
            //  6678157
            n1Loop2.N1 = new N1();
            n1Loop2.N1.EntityIdentifierCode_01 = "ST";
            n1Loop2.N1.IdentificationCodeQualifier_03 = "15";
            n1Loop2.N1.IdentificationCode_04 = "6678157";

            //  End N1 G05 Loop 2
            hlLoop1.G05Loop.N1Loop.Add(n1Loop2);

            //  Begin N1 G05 Loop 3
            var n1Loop3 = new Loop_N1_857();

            //  Bill to
            //  SAN
            //  1135309
            n1Loop3.N1 = new N1();
            n1Loop3.N1.EntityIdentifierCode_01 = "BT";
            n1Loop3.N1.IdentificationCodeQualifier_03 = "15";
            n1Loop3.N1.IdentificationCode_04 = "1135309";

            //  End N1 G05 Loop 3
            hlLoop1.G05Loop.N1Loop.Add(n1Loop3);

            //  Begin N1 G05 Loop 4
            var n1Loop4 = new Loop_N1_857();

            //  Vendor
            //  SAN
            //  2002450
            n1Loop4.N1 = new N1();
            n1Loop4.N1.EntityIdentifierCode_01 = "VN";
            n1Loop4.N1.IdentificationCodeQualifier_03 = "15";
            n1Loop4.N1.IdentificationCode_04 = "2002450";

            //  End N1 G05 Loop 4
            hlLoop1.G05Loop.N1Loop.Add(n1Loop4);

            //  End G05 Loop 1

            //  End HL Loop 1
            result.HLLoop.Add(hlLoop1);

            //  Begin HL Loop 2
            var hlLoop2 = new Loop_HL_857();

            //  Hierarchical level 2 order
            hlLoop2.HL = new HL();
            hlLoop2.HL.HierarchicalIDNumber_01 = "2";
            hlLoop2.HL.HierarchicalLevelCode_03 = "O";

            //  Begin TDS Loop
            hlLoop2.TDSLoop = new Loop_TDS_857();

            //  Total invoice before discount
            //  is applied is $3,837.50
            //  Amount subject to Terms
            //  discount is $3,837.50
            //  Discounted amount due
            //  is $2,187.36
            hlLoop2.TDSLoop.TDS = new TDS();
            hlLoop2.TDSLoop.TDS.Amount_01 = "383750";
            hlLoop2.TDSLoop.TDS.Amount_02 = "383750";
            hlLoop2.TDSLoop.TDS.Amount_03 = "218736";

            //  Purchase order number
            //  012323456789123
            //  Purchase order date
            //  of 01 / 06 / 98
            hlLoop2.TDSLoop.PRF = new PRF();
            hlLoop2.TDSLoop.PRF.PurchaseOrderNumber_01 = "0123456789123";
            hlLoop2.TDSLoop.PRF.ChangeOrderSequenceNumber_03 = "980106";

            //  End TDS Loop

            //  End HL Loop 2
            result.HLLoop.Add(hlLoop2);

            //  Begin HL Loop 3
            var hlLoop3 = new Loop_HL_857();

            //  Hierarchical level 3 pack
            hlLoop3.HL = new HL();
            hlLoop3.HL.HierarchicalIDNumber_01 = "3";
            hlLoop3.HL.HierarchicalLevelCode_03 = "P";

            //  Begin LX Loop
            hlLoop3.LXLoop = new Loop_LX_857();

            //  Loop start. Mandatory segment
            hlLoop3.LXLoop.LX = new LX();
            hlLoop3.LXLoop.LX.AssignedNumber_01 = "1";

            //  Repeating MAN
            hlLoop3.LXLoop.MAN = new List();

            //  UCC/EAN-128 Serial shipping
            //  container code format.
            //  Marks and numbers used to
            //  identify the carton
            //  00097800006400000012
            var man1 = new MAN();
            man1.MarksandNumbersQualifier_01 = "GM";
            man1.MarksandNumbers_02 = "00097800006400000012";
            hlLoop3.LXLoop.MAN.Add(man1);

            //  End LX Loop

            //  End HL Loop 3
            result.HLLoop.Add(hlLoop3);

            //  Begin HL Loop 4
            var hlLoop4 = new Loop_HL_857();

            //  Hierarchical level 4 item
            hlLoop4.HL = new HL();
            hlLoop4.HL.HierarchicalIDNumber_01 = "4";
            hlLoop4.HL.HierarchicalLevelCode_03 = "I";

            //  Begin IT1 Loop
            hlLoop4.IT1Loop = new Loop_IT1_857();

            //  Line item 1
            //  Shipped 2
            //  units
            //  at $8.40
            //  for each unit
            //  ISBN
            //  0835201031
            hlLoop4.IT1Loop.IT1 = new IT1();
            hlLoop4.IT1Loop.IT1.AssignedIdentification_01 = "1";
            hlLoop4.IT1Loop.IT1.QuantityInvoiced_02 = "2";
            hlLoop4.IT1Loop.IT1.UnitorBasisforMeasurementCode_03 = "UN";
            hlLoop4.IT1Loop.IT1.UnitPrice_04 = "8.4";
            hlLoop4.IT1Loop.IT1.BasisofUnitPriceCode_05 = "PE";
            hlLoop4.IT1Loop.IT1.ProductServiceIDQualifier_06 = "IB";
            hlLoop4.IT1Loop.IT1.ProductServiceID_07 = "0835201031";

            //  Repeating CTP
            hlLoop4.IT1Loop.CTP = new List();

            //  Suggested list price of
            //  $10.50
            //  Discount
            //  multiplier of .8
            //  (100 % -80 % = 20 % discount)
            var ctp1 = new CTP();
            ctp1.PriceIdentifierCode_02 = "SLP";
            ctp1.UnitPrice_03 = "10.5";
            ctp1.PriceMultiplierQualifier_06 = "DIS";
            ctp1.Multiplier_07 = ".8";
            hlLoop4.IT1Loop.CTP.Add(ctp1);

            //  End IT1 Loop

            //  End HL Loop 4
            result.HLLoop.Add(hlLoop4);

            //  Begin HL Loop 5
            var hlLoop5 = new Loop_HL_857();

            //  Hierarchical level 5 item
            hlLoop5.HL = new HL();
            hlLoop5.HL.HierarchicalIDNumber_01 = "5";
            hlLoop5.HL.HierarchicalLevelCode_03 = "I";

            //  Begin IT1 Loop
            hlLoop5.IT1Loop = new Loop_IT1_857();

            //  Line item 2
            //  Shipped 1
            //  unit
            //  at $24.00
            //  per each unit
            //  ISBN
            //  0835208338
            hlLoop5.IT1Loop.IT1 = new IT1();
            hlLoop5.IT1Loop.IT1.AssignedIdentification_01 = "2";
            hlLoop5.IT1Loop.IT1.QuantityInvoiced_02 = "1";
            hlLoop5.IT1Loop.IT1.UnitorBasisforMeasurementCode_03 = "UN";
            hlLoop5.IT1Loop.IT1.UnitPrice_04 = "24";
            hlLoop5.IT1Loop.IT1.BasisofUnitPriceCode_05 = "PE";
            hlLoop5.IT1Loop.IT1.ProductServiceIDQualifier_06 = "IB";
            hlLoop5.IT1Loop.IT1.ProductServiceID_07 = "0835208338";

            //  Repeating CTP
            hlLoop5.IT1Loop.CTP = new List();

            //  Suggested list price of
            //  $30.00
            //  Discount
            //  multiplier of .8
            //  (100 % -80 % = 20 % discount)
            var ctp2 = new CTP();
            ctp2.PriceIdentifierCode_02 = "SLP";
            ctp2.UnitPrice_03 = "30";
            ctp2.PriceMultiplierQualifier_06 = "DIS";
            ctp2.Multiplier_07 = ".8";
            hlLoop5.IT1Loop.CTP.Add(ctp2);

            //  End IT1 Loop

            //  End HL Loop 5
            result.HLLoop.Add(hlLoop5);

            return result;
        }
    }
}

More operations in ediFabric .NET

857 questions

When is an 857 used instead of an 856 and 810?

When both partners agree to settle on shipment, for example in evaluated receipt or consignment arrangements, so one transaction replaces two.

Is the 857 widely supported?

Less than the 856 and 810. Check the trading partner's implementation guide before choosing it.

How is the hierarchy organized?

Like the 856, with HL loops for the shipment, the order and the items, plus billing amounts.

How do I parse and generate X12 857 files in .NET, Python, Java and C?

In .NET, install EdiFabric and EdiFabric.Templates.X12, read the file with X12Reader into TS857 objects and write them back with X12Writer. From Python, Java or C, use ediFabric Native, which converts 857 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 857 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