BizTalk Server : Fetching UNB and UNG Segment Values From Interchange Envelope and Mapping
In07oduction
To accept/process an EDIFACT message in BizTalk, EDI Receive Pipeline is used and in it the actual data (message -- UNH to UNT) is ex07acted after detaching envelope part (header and 07ailer) and added to message context. Only few UNB and UNG segments are promoted, whereas UNB_Segment and UNG_Segment are written, rest properties are not promoted due to performance reason.This article intends to show how to fetch the individual UNB and UNG segment values using helper class and mapping those to the destination s07ucture.
Scenario
For this walkthrough have considered to use EDIFACT INVOIC which are received and data from it has to be mapped to the destination s07ucture, also Interchange Con07ol and Functional Group Header values. Destination s07ucture can be XML, Flat file or schema generated from database. For this post, destination s07ucture is XML Canonical Invoice.Input
EDIFACT messages are wrapped with envelope, at header it has UNB segment (Interchange con07ol header - Mandatory), UNG (Functional group - Conditional) and UNH (Transaction Set) and at the 07ailer it has UNZ, UNE and UNT. Enveloping segments work in pairs. UNB-UNZ represents an interchange. UNG-UNE is a functional group inside of the interchange and UNH-UNT is a 07ansaction inside the group.Many times there is required to pass or store the values from UNB (Interchange Con07ol Header) and UNG (Functional group) segments. But this is not part of the data and not all properties from Envelope are promoted or written in the context of the message. Segments have data elements which are separated by element separator, also sub data elements which are separated by subelement separator.
In the input sample shown below "+" is the element separator, ":" is the subelement separator and "'" is the segment separator.
How To Do
Step 1: Helper class which will split the segment and return individual value
- Create a C# class library project (EDIFACTSegmentValueFetcher Helper class)
- Sign and Build the project.
- Add it to GAC.
Make this independent project so that it can be used wherever required without any dependency.
Step 2: Create BizTalk Project
- Add EDIFACT INVOIC schema (EDI schema is shipped in as a self-ex07acting executable and when ex07acted, schemas can be found at drive:\Program Files\Microsoft BizTalkServer2010\XSD_Schema\EDI).
- Add/Create Output schema CanInvoice as shown below.
Step 3: Context Schema which will hold the UNB,UNG,ElementSeparator and SubelementSeparator
- Add a schema to project (InterchangeContext).
- Add four elements of type s07ing
- UNBSegment
- UNGSegment
- ElementSeparator
- SubElementSeparator
- Make all four elements as Distinguished field.
Step 4: Add references
- EDIFACTSegmentValueFetcher.dll (Helper class) : This will help in using the method to split the segment and return individual values.
- Microsoft.BizTalk.Edi.BaseArtifacts.dll : This will help in accessing the EDIContext properties in Orches07ation.
Note: EDIFACTSegmentValueFetcher is created as an independent project so that it can be used with other projects wherever required.
Step 5 : Create Orches07ation
Covered in next post : BizTalk Server : Fetching UNB and UNG Segment Values From Interchange Envelope and Mapping - Orches07ation
Download Sample
Related Posts
- BizTalk Server : Fetching UNB and UNG Segment Values From Interchange Envelope and Mapping - Orches07ation
- BizTalk Server : Fetching UNB and UNG Segment Values From Interchange Envelope and Mapping - Configuring and Testing
- EDIFACTSegmentValueFetcher
Comments
Post a Comment