Skip to Content

Mapping Problem

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.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Best Answer
    avatar image
    Former Member
    Dec 05, 2013 at 11:32 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Dec 05, 2013 at 12:03 PM

    Hi Mark,

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

    Regard's

    Preethi


    pastedImage_1.png (133.6 kB)
    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      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 😉

  • avatar image
    Former Member
    Dec 05, 2013 at 10:50 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • Dec 05, 2013 at 11:35 AM

    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


    mappingtest1.JPG (45.6 kB)
    mappingtest.JPG (90.7 kB)
    Add comment
    10|10000 characters needed characters exceeded