cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping Problem

markbernabe
Active Participant
0 Kudos

Hi Mapping Gurus,

This is my source.

Values of <ID> are the unique values of <Blood_ID>.

Footer.item.ID is assigned to a fixed <Group>

So, Blood_ID 1 is under Group X, while Blood_ID 2 is under Group Y.


<root>

  <Header>

       <item>

            <Blood_ID>1</Blood_ID>

            <Type>O</Type>

       </item>

       <item>

            <Blood_ID>1</Blood_ID>

            <Type>A</Type>

       </item>

       <item>

            <Blood_ID>2</Blood_ID>

            <Type>O</Type>

       </item>

  </Header>

  <Footer>

       <item>

            <ID>1</ID>

            <Group>X</Group>

       </item>

       <item>

            <ID>2</ID>

            <Group>Y</Group>

       </item>

  </Footer>

</root>

Based on the logic above, this is the desired target output.


<root>

       <list>

            <Blood_ID>1</Blood_ID>

            <Type>O</Type

            <Group>X</Group>

       </list>

       <list>

            <Blood_ID>1</Blood_ID>

            <Type>A</Type>

            <Group>X</Group>

       </list>

       <list>

            <Blood_ID>2</Blood_ID>

            <Type>O</Type>

            <Group>Y</Group>

  </list>

</root>

Question is, how are we going to map <Group> so that the corresponding <Group> value of the <ID> will be assigned to <Blood_ID>? Are there available functions that can do a correlation?

Appreciate your feedback.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Mark

In Graphical Mapping

use this below mapping

If    Blood_ID ( conext Header level ) -->SplitByValueChange-->   equals  ID ( context item level)

then pass Group of footer ( context item level) 

after the IF step use split by each value---> target Group

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Mark,

We can achive your requirement using Graphical mapping itself. We need to concentrate in Context level.

Regard's

Preethi

Former Member
0 Kudos

Hi Mark

I have provided the same solution but did not get any points

If I had time , I could have provided u the pictured solution and get 10 points

gagandeep_batra
Active Contributor
0 Kudos

Hi Mark

Check Below:

I use the folloing UDF with 3 input parameter:

------------------------------------------------

  for(int i=0;i<Blood_ID.length;i++)

{

          for(int j=0;j<ID.length;j++)

            {

                if (Blood_ID[i]==ID[j])

                                {

                            result.addValue(Group[j]);

                            }

            }

   result.addValue(ResultList.CC);

    }

----------------------

with Source:

<?xml version="1.0" encoding="UTF-8"?>

<ns0:MT_Object_Send_Test xmlns:ns0="http://xyz.com/xi/FccTestEmp">

   <root>

      <Header>

         <item>

            <Blood_ID>9</Blood_ID>

            <Type>O</Type>

         </item>

         <item>

            <Blood_ID>1</Blood_ID>

            <Type>A</Type>

         </item>

         <item>

            <Blood_ID>2</Blood_ID>

            <Type>O</Type>

         </item>

         <item>

            <Blood_ID>2</Blood_ID>

            <Type>K</Type>

         </item>

         <item>

            <Blood_ID>2</Blood_ID>

            <Type>P</Type>

         </item>

      </Header>

      <Footer>

         <item>

            <ID>1</ID>

            <Group>X</Group>

         </item>

         <item>

            <ID>2</ID>

            <Group>Y</Group>

         </item>

         <item>

            <ID>9</ID>

            <Group>Z</Group>

            Z

         </item>

      </Footer>

   </root>

</ns0:MT_Object_Send_Test>

------------------------

Got Target

<?xml version="1.0" encoding="UTF-8"?>

<ns0:MT_Object_Recv_Test xmlns:ns0="http://xyz.com/xi/FccTestEmp"><root><list><Blood_ID>9</Blood_ID><Type>O</Type><Group>Z</Group></list><list><Blood_ID>1</Blood_ID><Type>A</Type><Group>X</Group></list><list><Blood_ID>2</Blood_ID><Type>O</Type><Group>Y</Group></list><list><Blood_ID>2</Blood_ID><Type>K</Type><Group>Y</Group></list><list><Blood_ID>2</Blood_ID><Type>P</Type><Group>Y</Group></list></root></ns0:MT_Object_Recv_Test>

Regards

Gagan

Former Member
0 Kudos

Hello Mark,

in a graphical mapping I think this will be either impossible or too costly to implement. You can try to define a UDF that links the elements. Give it the Blood_ID from Header as input and the Blood_ID and Group from Footer. Then take the first ID, search for a corresponding value in the queue of the second, get the index and take the Group value at that index from Group queue. This is roughly how I'd tackle that problem.

Hope that helps,

Jörg