
BizTalk Server: EDI 856 – Mapping, Grouping and Sorting
This post explains in a brief detail how to create a simple BizTalk Server Integration to receive, transform, group and sort an EDI 856 Message (Advance Shipping Notice) to a simple Flat File representation. More specifically we are going to review how to:
- Review/Analyze an EDI 856 Message structure from three different perspectives: HTML (Conceptual), Raw Data and Xml Encoded
- Review how to map global data, groups of data using global keys, specific data using identifier keys
- Review how to isolate nodes, groups and sort data using key values
Assumptions
This blog post was written assuming the target audience is familiar with Microsoft BizTalk Server, Microsoft Visual Studio and Extensible Stylesheet Language Transformation (XSLT) code. It also assumes the target audience understand the basic concepts about Enterprise Application Integration and Electronic Data Interchange.
Scenario
The Business Scenario that will be covered with this blog post is pretty simple: A Trading Partner (Supplier) will transmit regularly Advance Shipping Notices (EDI 856 ASN) to a Manufacturing Center (Manufacturer). Every transmission can contain one or multiple Purchase Orders and every Purchase Order can contain one or several Rolls. All the Rolls will include the following measurements: Diameter, Width, Length and Gross Weight.
The Manufacturer’s internal platform requires to receive the data into a Delimited Flat File created with these rules:
- The Purchase Orders will be populated in ascending order
- The Rolls inside every Purchase Order will be extracted following the same order
- A Unique List with the Dimension ‘Width’ per Rolls’ Group will be created
- The Flat File will include a Header Record per PO+Width Unique Key and several Detail Records including the PO and Roll Data
Flat File Structure

Analysis
Let’s start the data analysis understanding the EDI 856 Structure. Generally speaking, an EDI document is a simple text file consisting of three parts: Header, Detail and Footer. This blog post covers the Detail Segment, it contains all of the business information that gives meaning to the document.
It’s easy and recommendable to use three different EDI representations to analyze and determine the mapping conditions.
- HTML : A human friendly presentation that is achieved through the use of templates.

- Raw Data: Raw data (also known as primary or source data) is the data that has not been processed for use. In EDI terms, text formatted using the EDI Standard.

- XML Encoded: XML is a flexible way to create and share common information formats. BizTalk Server uses XML internally to define the data and structure of business documents so we will considerate this EDI representation as well.

In a nutshell, we confirm the business scenario is accurate, the EDI Messages we are dealing with contain Purchase Orders (HL Loops where HL03 = ‘O’) and every Purchase Order contains several items (HL Loops where HL03=’I’), we will cover it in detail below. Something to consider “The loop segments (PO, Items) are included sequentially and, from an XML stand point, are not hierarchically related”.

Solution
We will create a BizTalk Application using the Publish-Subscribe Architecture Model. A Receive Port will pick up the EDI Messages from an input folder. BizTalk Server will resolve the Party and validate the Messages at the Receive Pipeline, it will publish these messages to the MessageBox Database. A send port will be configured to subscribe these messages, a map will be used to implement the transformation from EDI to a Generic Flat File and, the final result will be delivered to an output folder.

Coding
All right, it’s time to have some fun . The following steps will provide a high level walk through of this build process.
Up to this point, we have the base code required for the integration. The following section provides a step-by-step guideline to create the XSLT Map.
The map is ready.
Deployment
This blog post presents a simple publish-subscribe approach, all messages are published/subscribed using Ports in BizTalk. This solution requires the following BizTalk Artifacts:
Testing
Here we go, we are ready to test the solution. Once the Host Instance is running all we need to do is copy an EDI 856 file to the Input folder, BizTalk Server will pick up, validate, disassemble and translate it to a GenericASN instance. The result will be sent to the Output folder.

It’s ready. Fulfilling the Business Requirement, the EDI 856 Files are being translated to Flat Files, the results are grouped by Purchase Order/Measurement (Width) and sorted by Purchase Order Number. It’s time to reference my son’s favorite expression: It’s magic
Conclusions
In this blog post we have seen/explored a simple BizTalk Integration for EDI Messages, in specific the 856s – Advance Shipping Notice. I know, I know … I will cover the Acknowledgements, Exception Handling and Notifications in a future post, I think we have enough for now.
No Comments