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




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

Download Sample




Related Posts


ServerLess360


Comments

Popular posts from this blog

The request has both SAS authentication scheme and 'Bearer' authorization scheme. Only one scheme should be used

Getting Started with Logic Apps - AS2

How to Debug and Trace request in Azure APIM - Portal, Postman, RequestBin