thespot4sap.com independent sap information
 

get SAP Access - pay monthly

SAP Tutorials    Online SAP Training    SAP CBT's    SAP Forums    SAP Articles    SAP Jobs    SAP Resumes
  SAP Access    SAP Blogs    SAP Books     Links     SAP Vendor Directory     Submit Content    Search
Previous posts in BizTalk
Page 460 of 5577

How to join two schemas in a map when they contain namespaces

Blogger : MSDN Blogs
All posts : All posts by MSDN Blogs
Category : BizTalk
Blogged date : 2008 Aug 26

Problem Statement: I will be receiving two different messages (Message1 and Message2) inside orchestration each with multiple records. Now, I have to join these messages in a map inside orchestration based on TRANID and PROCID. So basically, I have to get the value of TRANID from Message1 and look for the record inside Message2 where value of PROCID matches to value of TRANID and get the value of SUM element and populate it in the output message and this process have to be repeated for every TRAN record of Message1.

clip_image002

Input Message1

clip_image004

Input Message2

clip_image006

Output Message

Solution: There is a very good blog which actually have got the solution for this problem http://geekswithblogs.net/synboogaloo/archive/2005/04/22/37335.aspx. But only thing is that in this case, input schema contains namespace which complicates the XPATH Query used in XSLT Call Template. Let us figure it out later, how to build XPATH query using namespaces in this scenario.

1) First, create the schema for the three messages.

2) Now create orchestration like below. It will receive these two input messages, constructs the output message using map inside Transform shape and then sends the output to a file location. Since we have to receive two different messages using File adapter and we do not have any unique identifier for correlation purpose, I used BTS.ReceivePortName for correlation. Though, this may not be very practical, I just want to demonstrate joining of two schemas when they have got namespace. But yes, make sure that both the receive locations are in the same Receive Port.

clip_image008

3) In the transform shape, select the msgInput1 and msgInput2 as Inputs and msgOutput as Output. Open the map now.

4) In the map, put a looping functoid as in the figure below. Link TRANID and DESC from input to output. The main thing remaining is to retrieve value of SUM from INPUT2 when TRANID matches to PROCID. Now drop a scripting functoid to the map and connect it to TRANID as Input and SUM as Output. It should look something like below.

clip_image010

5) Now, for the scripting functoid, things would have been something like below if the schema does not have the namespaces. But here, this XPATH query inside the ‘Inline XSLT Call Template’ will give us only blank results.

clip_image012

6) So we need to use the namespaces prefix in out query to get the desired output. Now we need to find out the namespace prefix being used in map for INPUT 2 schema. To find it out, we need to view the XSLT of the map. Therefore, we have to validate the map file first. So, right click the map file and say validate map. Now in the output, we will get a link to the map XSLT. Open this XSL file. Now in this XSL file, we can find the prefix used for the namespace “http:\\Input2” and that is ‘s1’.

clip_image014

7) Now, the XPATH Query inside the scripting functoid will look like below.

clip_image016

8) Deploy the solution and test it. That’s all.

You can download my Biztalk project and try it. If you got a better solution than this, please let me know. I would really be interested in knowing that.

I hope this post helps!


Read comments or post a reply to : How to join two schemas in a map when they contain namespaces
Page 460 of 5577

Newest posts
New Page 1

 

 

About Us   Contact Us   Privacy   Disclaimer   Feedback   Email Discussion   Newsletter  

Copyright © - Independent SAP Information
Learn XML, Guesthouses and B&B's