BizTalk Server : Fetching UNB and UNG Segment Values From Interchange Envelope and Mapping - Orchestration

{tocify} $title={Table of Contents}




Step 5: Create Orchestration(FetchInterchangeData)



Create messages



  • INVOICmsg - Conforming to EDIFACT INVOIC Schema
  •  InterchangeContextmsg - Conforming to InterchangeContext Schema
  •  Invoicemsg - Conforming to CanInvoice Schema

Create variables



  • UNBString - of type String
  •  xmlDoc - of type System.Xml.Document
3. Create Receive shape and configure it to accept INVOICmsg
4. Construct the context message(InterchangeContext) and the Invoice message which is the final output(Invoicemsg) using ConstructMessage shape with following :

Message Assignment shape


Here a variable xmlDoc of type System.Xml is used and its LoadXml method is used to construct the context message.

Why XmlDocument variable? The class "XmlDocument" is a super class for all XML messages, and hence it can hold any type of XML message and subsequently any type of orchestration message.

xmlDoc.LoadXml("<ns0:Contextxmlns:ns0='http://DemoEDIFACT_FetchingSegmentValues.InterchangeContext'><UNB></UNB><UNG></UNG><ElementSeparator></ElementSeparator><SubElementSeparator></SubElementSeparator></ns0:Context>");
InterchangeContextmsg = xmlDoc;
UNBString = INVOICmsg(EDI.UNB_Segment);

Assignment of EDI context values to the distinguished fields of context message

InterchangeContextmsg.UNB = INVOICmsg(EDI.UNB_Segment);
InterchangeContextmsg.UNG = INVOICmsg(EDI.UNG_Segment);

Fetching the element separator and sub element separator

InterchangeContextmsg.ElementSeparator = UNBString.Substring(3,1);
InterchangeContextmsg.SubElementSeparator = UNBString.Substring(8,1);


InterchangeContextmsg

Here we created a intermediate message and populated it with the values coming from EDI Envelope header(which are detach during pipeline processing), so that we can use it multi-input map.


Transform Shape


Here two source are used, the incoming INVOICmsg(for the business data) and the InterchangeContextmsg(for the segment/context data) which was created in above message assignment shape



Transform Shape

And destination as Invoicemsg
Transform Shape select destination

Suppose UNB1.1 segment is to be fetched then following is to be done

Configuring Scripting Functoid


1. Select Script type as External assembly

2. Select the script assembly EDIFACTSegmentValueFetcher
3. Select the script class as SegmentValueFetcher
4. Select the script method as fetchvalue


script  Functoid

Note: Assemblies will only be available for selection if they are present in GAC.


Passing inputs to Scripting Functoid


1. Input[0] as UNB, link from InterchangeContext UNB element

2. Input[1] as ElementSeparator link from InterchangeContext ElementSeparator element
3. Input[2] as SubElementSeparator link from InterchangeContext SubelementSeparator element 
4. Input[3] as "1" hard code value
5. Input[4] as "1" hard code value


script  Functoid configuration


5. Create Send shape and configure it to Invoicemsg
6. Configure the logical port


build project

7. Sign the project, build it and deploy it


Post a Comment

If you have any suggestions or questions or want to share something then please drop a comment

Previous Post Next Post