cancel
Showing results for 
Search instead for 
Did you mean: 

Evaluate the node position on the Message Mapping

Former Member
0 Kudos
Hi Experts
This is a problem in mapping, we are facing.
Source StructureTarget Structure
<A>
    <B>
        <Y/>
        <X/>
        <X/>
    </B>
</A>
<A>
    <B>
        <Y/>
        <X/>
    </B>
</A>
<A>
    <B>
        <X/>
    </B>
</A>

  Transformation rules 

  • Create an element "A" for each element "X". (DONE)
  • Create an element “Y” on the element “A”,   only if exist an element "Y" immediate superior to element "X. 

The multi-mapping is working well, but how to evaluate the position of the element "Y"?. Please someone suggest to me, any idea

P.S.

I checked the nexts blogs:

http://www.saptechnical.com/Tutorials/XI/NodeFunctions/Page1.htm

http://scn.sap.com/people/sravya.talanki2/blog/2005/08/16/message-mapping-simplified--part-i

http://scn.sap.com/people/sravya.talanki2/blog/2005/12/08/message-mapping-simplified-part-ii

Thanks in advance for your attention

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member184681
Active Contributor
0 Kudos

Hi Jose,

In general, it is difficult to evaluate the sequence of nodes in graphical mapping. Moreover, the solution to your problem depends on how the source structure is built in case more than one Y nodes exist. Would you explain a bit more in this area? Do the tags come like: YXXYXYXXX and so on, or rather only one Y node per each B node, etc.

Regards,

Greg

P.S. Please avoid double-posting the same question (http://scn.sap.com/thread/3186848). It makes getting the solution more difficult, both: for you and for those who want to help you, since the discussion is divided into two threads and lots of important information is missing in each of them. Please delete the redundant thread.

Former Member
0 Kudos

Hi Grzegorz.

The node "Y" in the source structure, can exist several times or none. I need to relate a node "X" with a node "Y", only if the node "Y" is the immediate superior node "X".

Examples of the source structure.

Source structure 1

<A>

    <B>

        <X/>

        <Y'/>

        <X'/>

    </B>

</A>

Expected target structure 1

<A>

    <B>

        <Y'/>

        <X'/>

    </B>

</A>

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

<A>

    <B>

        <X/>

    </B>

</A>

Source structure 2

<A>

    <B>

        <Y''/>

         <X''/>

        <Y'/>

        <X'/>

    </B>

</A>

Expected target structure 2

<A>

    <B>

        <Y''/>

              <X''/>

    </B>

</A>

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

<A>

    <B>

        <Y'/>

        <X'/>

    </B>

</A>

Source structure 3

<A>

    <B>

         <X''/>

         <X'/>

    </B>

</A>

Expected target structure 3

<A>

    <B>

       <X'/>

    </B>

</A>

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

<A>

    <B>

        <X''/>

    </B>

</A>

Thanks in advance

baskar_gopalakrishnan2
Active Contributor
0 Kudos

IMO, it is quite bit complicated to handle via graphical mapping. If you use java mapping where xml parsers like jdom would help you to navigate to any node level with respect to other node easily.

former_member184681
Active Contributor
0 Kudos

Dear Jose,

I partially agree with Baskar: this task could be difficult with only graphical mapping. But I also understand that starting over with Java mapping now that you have most part of your solution ready isn't really the desired solution . So I have an alternative for you. Use the following UDF to generate the Y node in the target structure:

String nodeX = "<X>";

String nodeY = "<Y>";

int nodeXpos = 0, nodeYpos = 0;

do {

nodeXpos = input.indexOf(nodeX);

nodeYpos = input.indexOf(nodeY);

System.out.println(input + " / " + nodeXpos + ", " + nodeYpos);

if (nodeXpos > nodeYpos && nodeYpos >= 0){

  result.addValue("");

  result.addValue(ResultList.CC);

}

else {

  result.addValue(ResultList.CC);

}

input = input.substring(nodeXpos + 1);

} while (input.indexOf(nodeX) > 0);

The important thing is to set the Execution Type = All Values of Queue/Context (although we will always have only one input) because we need to generate an output list. Also notice that you work on a string, not DOM tree for XML, which makes it much easier, quicker and far less resource-consuming.

Then map as follows:

A(return as XML) -> UDF -> Y

Regards,

Greg