# ANSI X12 EDI 856 Advance Ship Notice HL structure building

**URL:** <https://connective.celigo.com/t/ansi-x12-edi-856-advance-ship-notice-hl-structure-building/1025>\
**Category:** B2B Manager for EDI\
**Tags:** b2b-manager, edi-profile, edi, x12\
**Created:** [October 1, 2024, 3:25pm UTC](https://connective.celigo.com/t/ansi-x12-edi-856-advance-ship-notice-hl-structure-building/1025 "2024-10-01T15:25:36Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![paultopham](https://avatars.discourse-cdn.com/v4/letter/p/e5b9ba/32.png) [@paultopham](https://connective.celigo.com/u/paultopham)\
**Post date:** [October 1, 2024, 3:25pm UTC](https://connective.celigo.com/t/ansi-x12-edi-856-advance-ship-notice-hl-structure-building/1025/1 "2024-10-01T15:25:36Z")

</div>

Anyone using Celigo for X12 EDI?

In the sample below, there are 4 different Hierarchical Levels represented

Two things I need to do when mapping these segments.

- Establish and maintain a counter throughout a Shipment that is accessed, written out to the HL01 element and incremented for the next one. 
- Establish the proper parent HL number to be written out for each subordinate HL

A shipment may have many Items in a Pack, many Packs in an Order and many Orders in a Shipment.

The HL segments are used to structure the document with a single Shipment level per ASN, all Orders pointing back to the Shipment level as their parent, many Packs pointing back to their Order level as their parent and many Items pointing back to their Pack level as the parent.

**HL-S\*1\*\*S**

**HL-O\*2\*1 - 1= parent HL**

**HL-P\*3\*2 - 2 = parent HL**

**HL-I\*4\*3 - 3 = parent HL**

**HL-P\*5\*2 - 2 = parent HL**

**HL-I\*6\*5 - 5 = parent H"L**

Sample Output:

BSN\*00\*WLD0314938\*20240927\*0930\*0001 ~ Shipment Id here - BSN02 = "WLD0314938"

**HL-S\*1\*\*S~ (Shipment)**

DTM\*011\*20240927~

**HL-O\*2\*1\*O~ (Order)**

PRF\*P00815403~ \*\*\* Customer PO Number

**HL-P\*3\*2\*P~ (Pack)**

MAN\*GM\*00007111061143120875\*\*CP\*NA~ \*\*\*\* Carton ID Number

**HL-I\*4\*3\*I~ (Item)**

LIN\*1\*SK\*LPC68EBGH1\*\*\*UP\*711106926872~ \*\*\*\* Item data

SN1\*\*1\*EA~

**HL-P\*5\*2\*P~ (Pack) \*\*\*\*\* Second Carton Id)**

MAN\*GM\*00007111061143120868\*\*CP\*NA~ \*\*\*\*\* Second Carton Id

**HL-I\*6\*5\*I~ (Item)**

LIN\*2\*SK\*LPJRSC57HATVNH1\*\*\*UP\*711106050287~ \*\*\*\* Second Item Data

SN1\*\*1\*EA~

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![tylerlamparter](https://sea1.discourse-cdn.com/flex001/user_avatar/connective.celigo.com/tylerlamparter/32/9204_2.png) [@tylerlamparter](https://connective.celigo.com/u/tylerlamparter)\
**Post date:** [October 1, 2024, 5:56pm UTC](https://connective.celigo.com/t/ansi-x12-edi-856-advance-ship-notice-hl-structure-building/1025/2 "2024-10-01T17:56:11Z")

</div>

@paultopham can you follow the responses here and see if it solves your question? [https://connective.celigo.com/t/creating-hl-segments/232](https://connective.celigo.com/t/creating-hl-segments/232)

---

<div class="post-metadata">

**Author:** ![paultopham](https://avatars.discourse-cdn.com/v4/letter/p/e5b9ba/32.png) [@paultopham](https://connective.celigo.com/u/paultopham)\
**Post date:** [October 1, 2024, 7:40pm UTC](https://connective.celigo.com/t/ansi-x12-edi-856-advance-ship-notice-hl-structure-building/1025/3 "2024-10-01T19:40:02Z")

</div>

Hi Tyler.

For the HL01 perhaps, as it is a one up number that is simply incremented for each HL segment in the document. Not sure how to do it, but it has to be simple.

Hard to explain and hard for me to understand the example as when it comes to scripting I'm a hammer - thumb guy.

Minimally the feed needs to be sorted by Load Id (shipment), Purchase Order Number, Carton Id and Item Number.

So I would think that each counter needs to be initialized based on each break's values as they occur and incremented when the break level value of that level remains the same.

So, Shipment level HL01 = 1 and there is no parent

Order level (and all Order Levels in the document) point back to the parent so parent id HL02 element is 1.

Pack level points back the the active Order Level and remains the same until the Order Number changes.

Item level points back to the current Pack Level. All Packs have the same parent until the Carton ID changes.

Also, each Envelope sent can contain from 1 to N ASNs.

If a solution could be put together where the variables were named ShipmentCounter, OrderCounter, PackCounter and ItemCounter it might make more sense for me.

One problem I am having is that the data in the example is not truly an X12 ASN and doesn't appear to follow the multi layered structure of the ANSI 856 that I am deraling with.

---

<div class="post-metadata">

**Author:** ![tylerlamparter](https://sea1.discourse-cdn.com/flex001/user_avatar/connective.celigo.com/tylerlamparter/32/9204_2.png) [@tylerlamparter](https://connective.celigo.com/u/tylerlamparter)\
**Post date:** [October 1, 2024, 11:59pm UTC](https://connective.celigo.com/t/ansi-x12-edi-856-advance-ship-notice-hl-structure-building/1025/4 "2024-10-01T23:59:03Z")

</div>

@paultopham unfortunately, the preMap script is the only option for handling this now. We have some counter functionality, but not something to handle this as of now. If you send me your input JSON data, I could help with a script.

---

<div class="post-metadata">

**Author:** ![paultopham](https://avatars.discourse-cdn.com/v4/letter/p/e5b9ba/32.png) [@paultopham](https://connective.celigo.com/u/paultopham)\
**Post date:** [October 2, 2024, 8:16pm UTC](https://connective.celigo.com/t/ansi-x12-edi-856-advance-ship-notice-hl-structure-building/1025/5 "2024-10-02T20:16:37Z")

</div>

Current process works from flat files, not directly from a 365 JSON entity. Trying to see if the flat file is necessary at this point. Will do an extract and send it along.

---

<div class="post-metadata">

**Author:** ![paultopham](https://avatars.discourse-cdn.com/v4/letter/p/e5b9ba/32.png) [@paultopham](https://connective.celigo.com/u/paultopham)\
**Post date:** [October 2, 2024, 8:26pm UTC](https://connective.celigo.com/t/ansi-x12-edi-856-advance-ship-notice-hl-structure-building/1025/6 "2024-10-02T20:26:49Z")

</div>

{ "@odata.context":"[https://gibson-prod.operations.dynamics.com/data/$metadata#GBIASNsv2","value":[](https://gibson-prod.operations.dynamics.com/data/$metadata#GBIASNsv2%22,%22value%22:[) { "dataAreaId":"gmi","ShipmentId":"SID0319727","LoadShipConfirmUTCDateTime":"2024-09-30T15:41:25Z","SCAC":"","PrintedBy":"Jeremy.Reardon","ZipCode":"64161","ProNum":"","CarrierCode":"","ShipConfirmUTCDateTime":"2024-09-30T15:41:25Z","Street":"4001 N Norfleet Rd,","WorkQty":1,"State":"MO","LabelItemId":"AMJBJPCTS","WorkId":"WID0001534368","LineNum":1,"PurchOrderFormNum":"P00837376","CountryRegionId":"USA","Voided":"No","PrivateForParty":0,"TimeZone":null,"City":"Kansas City","StreetNumber":"","ShipmentStatus":"Shipped","LoadId":"WLD0315269","InventUnitId":"EACH","PackingSlipId":"PKS0284066","CarrierServiceCode":"","TrailerNumber":"","InventSiteId":"3050","DropOffUTCDateTime":"2024-10-08T11:41:25Z","ManifestedWeightUOM":"","InventLocationId":"MON","CustomerReq":"P00837376","ManifestedWeight":0,"itemBarCode":"711106157627","SalesId":"SOGMI0382592","Address":"4001 N Norfleet Rd,\nKansas City, MO 64161\nUSA","BuildingCompliment":"","WaveLabelId":"00007111061143316483","OrgNumber":"WH07","LabelQty":1,"CustAccount":"0MO540","DeliveryName":"Musicians Friend Inc","VoyageNum":"","RouteCode":"","WorkLineNum":1,"VesselName":"","TractorNumber":"","SalesStatus":"Backorder","NumberOfLabels":8,"FreightTermCode":"","DlvTermId":"","CarrierGroupCode":"","LabelItemName":"Jimmy Page 1964 SJ-200, signed","Printed":"Yes","InventTransId":"LID120040567","InvoiceAccount":"0OR540","LoadStatus":"Shipped","LabelUnitId":"EACH","BillOfLadingId":"","InventQty":1,"SealNum":"","PostBox":"","PrintedDateTime":"2024-09-30T15:41:24Z","PackingSlipDate":"1900-01-01T12:00:00Z" },{ "dataAreaId":"gmi","ShipmentId":"SID0319727","LoadShipConfirmUTCDateTime":"2024-09-30T15:41:25Z","SCAC":"","PrintedBy":"Jeremy.Reardon","ZipCode":"64161","ProNum":"","CarrierCode":"","ShipConfirmUTCDateTime":"2024-09-30T15:41:25Z","Street":"4001 N Norfleet Rd,","WorkQty":1,"State":"MO","LabelItemId":"AMJBJPCTS","WorkId":"WID0001534368","LineNum":1,"PurchOrderFormNum":"P00837376","CountryRegionId":"USA","Voided":"No","PrivateForParty":0,"TimeZone":null,"City":"Kansas City","StreetNumber":"","ShipmentStatus":"Shipped","LoadId":"WLD0315269","InventUnitId":"EACH","PackingSlipId":"PKS0284066","CarrierServiceCode":"","TrailerNumber":"","InventSiteId":"3050","DropOffUTCDateTime":"2024-10-08T11:41:25Z","ManifestedWeightUOM":"","InventLocationId":"MON","CustomerReq":"P00837376","ManifestedWeight":0,"itemBarCode":"711106157627","SalesId":"SOGMI0382592","Address":"4001 N Norfleet Rd,\nKansas City, MO 64161\nUSA","BuildingCompliment":"","WaveLabelId":"00007111061143316490","OrgNumber":"WH07","LabelQty":1,"CustAccount":"0MO540","DeliveryName":"Musicians Friend Inc","VoyageNum":"","RouteCode":"","WorkLineNum":1,"VesselName":"","TractorNumber":"","SalesStatus":"Backorder","NumberOfLabels":8,"FreightTermCode":"","DlvTermId":"","CarrierGroupCode":"","LabelItemName":"Jimmy Page 1964 SJ-200, signed","Printed":"Yes","InventTransId":"LID120040567","InvoiceAccount":"0OR540","LoadStatus":"Shipped","LabelUnitId":"EACH","BillOfLadingId":"","InventQty":1,"SealNum":"","PostBox":"","PrintedDateTime":"2024-09-30T15:41:24Z","PackingSlipDate":"1900-01-01T12:00:00Z" },{ "dataAreaId":"gmi","ShipmentId":"SID0319727","LoadShipConfirmUTCDateTime":"2024-09-30T15:41:25Z","SCAC":"","PrintedBy":"Jeremy.Reardon","ZipCode":"64161","ProNum":"","CarrierCode":"","ShipConfirmUTCDateTime":"2024-09-30T15:41:25Z","Street":"4001 N Norfleet Rd,","WorkQty":1,"State":"MO","LabelItemId":"AMJBJPCTS","WorkId":"WID0001534368","LineNum":1,"PurchOrderFormNum":"P00837376","CountryRegionId":"USA","Voided":"No","PrivateForParty":0,"TimeZone":null,"City":"Kansas City","StreetNumber":"","ShipmentStatus":"Shipped","LoadId":"WLD0315269","InventUnitId":"EACH","PackingSlipId":"PKS0284066","CarrierServiceCode":"","TrailerNumber":"","InventSiteId":"3050","DropOffUTCDateTime":"2024-10-08T11:41:25Z","ManifestedWeightUOM":"","InventLocationId":"MON","CustomerReq":"P00837376","ManifestedWeight":0,"itemBarCode":"711106157627","SalesId":"SOGMI0382592","Address":"4001 N Norfleet Rd,\nKansas City, MO 64161\nUSA","BuildingCompliment":"","WaveLabelId":"00007111061143316506","OrgNumber":"WH07","LabelQty":1,"CustAccount":"0MO540","DeliveryName":"Musicians Friend Inc","VoyageNum":"","RouteCode":"","WorkLineNum":1,"VesselName":"","TractorNumber":"","SalesStatus":"Backorder","NumberOfLabels":8,"FreightTermCode":"","DlvTermId":"","CarrierGroupCode":"","LabelItemName":"Jimmy Page 1964 SJ-200, signed","Printed":"Yes","InventTransId":"LID120040567","InvoiceAccount":"0OR540","LoadStatus":"Shipped","LabelUnitId":"EACH","BillOfLadingId":"","InventQty":1,"SealNum":"","PostBox":"","PrintedDateTime":"2024-09-30T15:41:24Z","PackingSlipDate":"1900-01-01T12:00:00Z" },{ "dataAreaId":"gmi","ShipmentId":"SID0319727","LoadShipConfirmUTCDateTime":"2024-09-30T15:41:25Z","SCAC":"","PrintedBy":"Jeremy.Reardon","ZipCode":"64161","ProNum":"","CarrierCode":"","ShipConfirmUTCDateTime":"2024-09-30T15:41:25Z","Street":"4001 N Norfleet Rd,","WorkQty":1,"State":"MO","LabelItemId":"AMJBJPCTS","WorkId":"WID0001534368","LineNum":1,"PurchOrderFormNum":"P00837376","CountryRegionId":"USA","Voided":"No","PrivateForParty":0,"TimeZone":null,"City":"Kansas City","StreetNumber":"","ShipmentStatus":"Shipped","LoadId":"WLD0315269","InventUnitId":"EACH","PackingSlipId":"PKS0284066","CarrierServiceCode":"","TrailerNumber":"","InventSiteId":"3050","DropOffUTCDateTime":"2024-10-08T11:41:25Z","ManifestedWeightUOM":"","InventLocationId":"MON","CustomerReq":"P00837376","ManifestedWeight":0,"itemBarCode":"711106157627","SalesId":"SOGMI0382592","Address":"4001 N Norfleet Rd,\nKansas City, MO 64161\nUSA","BuildingCompliment":"","WaveLabelId":"00007111061143316513","OrgNumber":"WH07","LabelQty":1,"CustAccount":"0MO540","DeliveryName":"Musicians Friend Inc","VoyageNum":"","RouteCode":"","WorkLineNum":1,"VesselName":"","TractorNumber":"","SalesStatus":"Backorder","NumberOfLabels":8,"FreightTermCode":"","DlvTermId":"","CarrierGroupCode":"","LabelItemName":"Jimmy Page 1964 SJ-200, signed","Printed":"Yes","InventTransId":"LID120040567","InvoiceAccount":"0OR540","LoadStatus":"Shipped","LabelUnitId":"EACH","BillOfLadingId":"","InventQty":1,"SealNum":"","PostBox":"","PrintedDateTime":"2024-09-30T15:41:24Z","PackingSlipDate":"1900-01-01T12:00:00Z" },{ "dataAreaId":"gmi","ShipmentId":"SID0319727","LoadShipConfirmUTCDateTime":"2024-09-30T15:41:25Z","SCAC":"","PrintedBy":"Jeremy.Reardon","ZipCode":"64161","ProNum":"","CarrierCode":"","ShipConfirmUTCDateTime":"2024-09-30T15:41:25Z","Street":"4001 N Norfleet Rd,","WorkQty":1,"State":"MO","LabelItemId":"AMJBJPCTS","WorkId":"WID0001534368","LineNum":1,"PurchOrderFormNum":"P00837376","CountryRegionId":"USA","Voided":"No","PrivateForParty":0,"TimeZone":null,"City":"Kansas City","StreetNumber":"","ShipmentStatus":"Shipped","LoadId":"WLD0315269","InventUnitId":"EACH","PackingSlipId":"PKS0284066","CarrierServiceCode":"","TrailerNumber":"","InventSiteId":"3050","DropOffUTCDateTime":"2024-10-08T11:41:25Z","ManifestedWeightUOM":"","InventLocationId":"MON","CustomerReq":"P00837376","ManifestedWeight":0,"itemBarCode":"711106157627","SalesId":"SOGMI0382592","Address":"4001 N Norfleet Rd,\nKansas City, MO 64161\nUSA","BuildingCompliment":"","WaveLabelId":"00007111061143316520","OrgNumber":"WH07","LabelQty":1,"CustAccount":"0MO540","DeliveryName":"Musicians Friend Inc","VoyageNum":"","RouteCode":"","WorkLineNum":1,"VesselName":"","TractorNumber":"","SalesStatus":"Backorder","NumberOfLabels":8,"FreightTermCode":"","DlvTermId":"","CarrierGroupCode":"","LabelItemName":"Jimmy Page 1964 SJ-200, signed","Printed":"Yes","InventTransId":"LID120040567","InvoiceAccount":"0OR540","LoadStatus":"Shipped","LabelUnitId":"EACH","BillOfLadingId":"","InventQty":1,"SealNum":"","PostBox":"","PrintedDateTime":"2024-09-30T15:41:24Z","PackingSlipDate":"1900-01-01T12:00:00Z" },{ "dataAreaId":"gmi","ShipmentId":"SID0319727","LoadShipConfirmUTCDateTime":"2024-09-30T15:41:25Z","SCAC":"","PrintedBy":"Jeremy.Reardon","ZipCode":"64161","ProNum":"","CarrierCode":"","ShipConfirmUTCDateTime":"2024-09-30T15:41:25Z","Street":"4001 N Norfleet Rd,","WorkQty":1,"State":"MO","LabelItemId":"AMJBJPCTS","WorkId":"WID0001534368","LineNum":1,"PurchOrderFormNum":"P00837376","CountryRegionId":"USA","Voided":"No","PrivateForParty":0,"TimeZone":null,"City":"Kansas City","StreetNumber":"","ShipmentStatus":"Shipped","LoadId":"WLD0315269","InventUnitId":"EACH","PackingSlipId":"PKS0284066","CarrierServiceCode":"","TrailerNumber":"","InventSiteId":"3050","DropOffUTCDateTime":"2024-10-08T11:41:25Z","ManifestedWeightUOM":"","InventLocationId":"MON","CustomerReq":"P00837376","ManifestedWeight":0,"itemBarCode":"711106157627","SalesId":"SOGMI0382592","Address":"4001 N Norfleet Rd,\nKansas City, MO 64161\nUSA","BuildingCompliment":"","WaveLabelId":"00007111061143316537","OrgNumber":"WH07","LabelQty":1,"CustAccount":"0MO540","DeliveryName":"Musicians Friend Inc","VoyageNum":"","RouteCode":"","WorkLineNum":1,"VesselName":"","TractorNumber":"","SalesStatus":"Backorder","NumberOfLabels":8,"FreightTermCode":"","DlvTermId":"","CarrierGroupCode":"","LabelItemName":"Jimmy Page 1964 SJ-200, signed","Printed":"Yes","InventTransId":"LID120040567","InvoiceAccount":"0OR540","LoadStatus":"Shipped","LabelUnitId":"EACH","BillOfLadingId":"","InventQty":1,"SealNum":"","PostBox":"","PrintedDateTime":"2024-09-30T15:41:24Z","PackingSlipDate":"1900-01-01T12:00:00Z" },{ "dataAreaId":"gmi","ShipmentId":"SID0319727","LoadShipConfirmUTCDateTime":"2024-09-30T15:41:25Z","SCAC":"","PrintedBy":"Jeremy.Reardon","ZipCode":"64161","ProNum":"","CarrierCode":"","ShipConfirmUTCDateTime":"2024-09-30T15:41:25Z","Street":"4001 N Norfleet Rd,","WorkQty":1,"State":"MO","LabelItemId":"AMJBJPCTS","WorkId":"WID0001534368","LineNum":2,"PurchOrderFormNum":"P00837376","CountryRegionId":"USA","Voided":"No","PrivateForParty":0,"TimeZone":null,"City":"Kansas City","StreetNumber":"","ShipmentStatus":"Shipped","LoadId":"WLD0315269","InventUnitId":"EACH","PackingSlipId":"PKS0284066","CarrierServiceCode":"","TrailerNumber":"","InventSiteId":"3050","DropOffUTCDateTime":"2024-10-08T11:41:25Z","ManifestedWeightUOM":"","InventLocationId":"MON","CustomerReq":"P00837376","ManifestedWeight":0,"itemBarCode":"711106157627","SalesId":"SOGMI0382592","Address":"4001 N Norfleet Rd,\nKansas City, MO 64161\nUSA","BuildingCompliment":"","WaveLabelId":"00007111061143316544","OrgNumber":"WH07","LabelQty":1,"CustAccount":"0MO540","DeliveryName":"Musicians Friend Inc","VoyageNum":"","RouteCode":"","WorkLineNum":2,"VesselName":"","TractorNumber":"","SalesStatus":"Backorder","NumberOfLabels":8,"FreightTermCode":"","DlvTermId":"","CarrierGroupCode":"","LabelItemName":"Jimmy Page 1964 SJ-200, signed","Printed":"Yes","InventTransId":"LID120040567","InvoiceAccount":"0OR540","LoadStatus":"Shipped","LabelUnitId":"EACH","BillOfLadingId":"","InventQty":1,"SealNum":"","PostBox":"","PrintedDateTime":"2024-09-30T15:41:24Z","PackingSlipDate":"1900-01-01T12:00:00Z" },{ "dataAreaId":"gmi","ShipmentId":"SID0319727","LoadShipConfirmUTCDateTime":"2024-09-30T15:41:25Z","SCAC":"","PrintedBy":"Jeremy.Reardon","ZipCode":"64161","ProNum":"","CarrierCode":"","ShipConfirmUTCDateTime":"2024-09-30T15:41:25Z","Street":"4001 N Norfleet Rd,","WorkQty":1,"State":"MO","LabelItemId":"AMJBJPCTS","WorkId":"WID0001534368","LineNum":2,"PurchOrderFormNum":"P00837376","CountryRegionId":"USA","Voided":"No","PrivateForParty":0,"TimeZone":null,"City":"Kansas City","StreetNumber":"","ShipmentStatus":"Shipped","LoadId":"WLD0315269","InventUnitId":"EACH","PackingSlipId":"PKS0284066","CarrierServiceCode":"","TrailerNumber":"","InventSiteId":"3050","DropOffUTCDateTime":"2024-10-08T11:41:25Z","ManifestedWeightUOM":"","InventLocationId":"MON","CustomerReq":"P00837376","ManifestedWeight":0,"itemBarCode":"711106157627","SalesId":"SOGMI0382592","Address":"4001 N Norfleet Rd,\nKansas City, MO 64161\nUSA","BuildingCompliment":"","WaveLabelId":"00007111061143316551","OrgNumber":"WH07","LabelQty":1,"CustAccount":"0MO540","DeliveryName":"Musicians Friend Inc","VoyageNum":"","RouteCode":"","WorkLineNum":2,"VesselName":"","TractorNumber":"","SalesStatus":"Backorder","NumberOfLabels":8,"FreightTermCode":"","DlvTermId":"","CarrierGroupCode":"","LabelItemName":"Jimmy Page 1964 SJ-200, signed","Printed":"Yes","InventTransId":"LID120040567","InvoiceAccount":"0OR540","LoadStatus":"Shipped","LabelUnitId":"EACH","BillOfLadingId":"","InventQty":1,"SealNum":"","PostBox":"","PrintedDateTime":"2024-09-30T15:41:24Z","PackingSlipDate":"1900-01-01T12:00:00Z" }] }
