Skip to Content

content conversion in mapping

Hi,

I have a xml document that comes into a mapping as a result of lookup to SAP in XI. The xml structure is

<MT_I_RFC>

<HEADER>1212</HEADER>

<MESSAGE>TEST MESSAGE/DO NOT ERASE/TEST</MESSAGE>

</MT_I_RFC>

<MESSAGE> is 0:1.

In my mapping I need to take the content in <MESSAGE> and when I find / in the message, the content needs to be split into multiple resulting tags like below

structure of result is

<MT_FF>

<ROW>

<MESSAGE></MESSAGE>

</ROW>

</MT_FF>

<ROW> and <MESSAGE> is 0..unbounded.

After mapping the above input the result should be:

<MT_FF>

<ROW>

<MESSAGE>TEST MESSAGE</MESAGE>

</ROW>

<ROW>

<MESSAGE>DO NOT ERASE</MESSAGE>

</ROW>

<ROW>

<MESSAGE>TEST</MESSAGE>

<ROW>

</MT_FF>

can I please know how to achieve this? thanks for your help in advance.

Edited by: developer on Jul 8, 2008 5:50 AM

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jul 08, 2008 at 06:54 AM

    Hi,

    Assuming source element MESSAGE occurrence is 0..1 and that of target elements ROW and MESSAGE is 0..unbounded, you can do something like this -

    Map source element MESSAGE to target element MESSAGE using UDF split() shown below -

    public void split(String[] a,ResultList result,Container container){
       int i;
       String [] temp = a[0].split("/");
       for( i = 0; i < temp.length; i++ ) {
          result.addValue(temp<i>);
          result.addContextChange();
       }
    }

    And map source element MESSAGE to target element ROW using UDF split2() shown below -

    public void split2(String[] a,ResultList result,Container container){
       int i;
       String [] temp = a[0].split("/");
       for( i = 0; i < temp.length; i++ ) {
          result.addValue(temp<i>);
       }
    }

    Edit: These are advanced UDFs. i.e. while creating the UDFs, under Cache, select the radio button next to Queue. This allows you to modify the entire message queue in the UDF.

    Hope this helps.

    Regards,

    Riyaz

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jul 08, 2008 at 03:58 AM

    Hi,

    You can achieve this using Java Code/user defined function or Java Mapping, where you can generate the target structure as you required... So use Java Code to achieve the same

    Regards, Moorthy

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Siva Veerapalli

      Hi,

      Its possible with adding advanced UDF. Even you can existing Node Functions also such as SplitByValue, etc..

      Please can you give me the data that you will be sending as input from Source mapping, whihc have formated to target mapping as given in your previous post, so I can try for exact solution

      <MT_FF>

      <ROW>

      <MESSAGE>TEST MESSAGE</MESAGE>

      </ROW>

      <ROW>

      <MESSAGE>DO NOT ERASE</MESSAGE>

      </ROW>

      <ROW>

      <MESSAGE>TEST</MESSAGE>

      <ROW>

      </MT_FF>

      Thanks

      Swarup

      Edited by: Swarup Sawant on Jul 8, 2008 7:54 AM

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.