Skip to Content
author's profile photo Former Member
Former Member

Can't get graphical mapping to work - subelements

Hello,

I'm new to SAP XI, and I'm struggling with a graphical mapping.

This is what I have in the source message schema:

<Root> 
  <Group>             (occurrance 1..1)
     <A>              (occurrance 1..n)
        <Value>       (occurrance 1..1)
        <B>           (occurrance 0..n)
           <Value>    (occurrance 1..1)

So element "A" can have possible 0, 1 or more subelements "B". Element A has always a subelement "Value", and if B occurs, every occurrance of B has also a subelement "Value".

The purpose of the mapping is: if there are "B" subelements, then map the "Value" subelement of B to the target message element (and this for each "B" subelement). If there are no "B" subelements, then map the "Value" subelement of A to the target message element.

The example message instance I have is:

<Root>
  <Group>
    <A>
       <Value>test1</Value>
    </A>
    <A>
       <Value>test2</Value>
       <B>
         <Value>test3</Value>
       </B>
       <B>
         <Value>test4</Value>
       </B>
    </A>
    <A>
       <Value>test5</Value>
    </A>
  </Group>
</Root>

This would have to be mapped to a target result which looks like this:

<Results>
   <Records>
      <Result>test1</Result>
      <Result>test3</Result>
      <Result>test4</Result>
      <Result>test5</Result>
   </Records>
</Results>

(as you probably already remarked, the "test2" value should not be mapped to the target, because the A-parent element has B subelements, so the values should be taken from that element.)

I already tried several things and combinations (exists node function, splitbyvalue,...) that I found on the forum, but I don't succeed in creating the correct structure.

Can you guys help me ? Thank you very much in advance !

(I marked this thread as a question so I can reward the answers)

Kindly,

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Nov 28, 2007 at 10:17 AM

    Plz send the target structure also.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 28, 2007 at 11:13 AM

    Hello,

    you can check the existence of a B value with the function exists.

    The output is a boolean value that you can give to an if-then-else function.

    then-value is the B value

    else-value is the A value

    output of the if-then-else function goes to the result value. I guess it's necessary

    to use a remove-context function for the output.

    This solution worked if their exists at least one B value correctly but (at the moment)

    not for for A values without B values.

    A least i guess it goes in the right direction...

    Regards

    Patrick

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.