cancel
Showing results for 
Search instead for 
Did you mean: 

MultiMapping Split 1 to N issue

Former Member
0 Kudos

Hi all,

in my scenario I have to realize a Message Mapping (with MultiMapping) to split 1 MT into N others MT of the same type (Message Instance Level).

I summarize in following the MT-source and MT-target structures.

Source MT Structure (Messages Occurrence 1)


<Messages>						1..1
   <Message1>						1..1
      <MT_SPLIT>					1..1
         <PAYLOAD>				        0..1
            <B001>				        0..N
               <PAYLOAD1>				1..1
                  <KEY1>K1A</KEY1>			1..1
                  <VALUE>V1A</VALUE>		        1..1
            <B002>					0..N
               <PAYLOAD2>				1..1
                  <KEY2>K2C</KEY2>			1..1
                  <VALUE>V2C</VALUE>		        1..1

Target MT Structure (Messages Occurrence 0..UNBOUNDED)


<Messages>						1..1
   <Message1>						1..1
      <MT_SPLIT>					0..N
         <PAYLOAD>				        0..1
            <B001>				        0..N
               <PAYLOAD1>				1..1
                  <KEY1>K1A</KEY1>			1..1
                  <VALUE>V1A</VALUE>		        1..1
            <B002>					0..N
               <PAYLOAD2>				1..1
                  <KEY2>K2C</KEY2>			1..1
                  <VALUE>V2C</VALUE>		        1..1

In this way I need to realize the type of behaviour shown in the following example.

Source Instance


<?xml version="1.0" encoding="UTF-8"?>
<ns0:Messages xmlns:ns0="http://sap.com/xi/XI/SplitAndMerge">
   <ns0:Message1>
      <ns1:MT_SPLIT xmlns:ns1="http://test.com">
         <PAYLOAD>
            <B001>
               <PAYLOAD1>
                  <KEY1>K1A</KEY1>
                  <VALUE>V1A</VALUE>
               </PAYLOAD1>
            </B001>
            <B001>
               <PAYLOAD1>
                  <KEY1>K1B</KEY1>
                  <VALUE>V1B</VALUE>
               </PAYLOAD1>
            </B001>
            <B002>
               <PAYLOAD2>
                  <KEY2>K2A</KEY2>
                  <VALUE>V2A</VALUE>
               </PAYLOAD2>
            </B002>
            <B002>
               <PAYLOAD2>
                  <KEY2>K2B</KEY2>
                  <VALUE>V2B</VALUE>
               </PAYLOAD2>
            </B002>
            <B002>
               <PAYLOAD2>
                  <KEY2>K2C</KEY2>
                  <VALUE>V2C</VALUE>
               </PAYLOAD2>
            </B002>
         </PAYLOAD>
      </ns1:MT_SPLIT>
   </ns0:Message1>
</ns0:Messages>

Target Instance (my target result)

<?xml version="1.0" encoding="UTF-8" ?> 
<ns0:Messages xmlns:ns0="http://sap.com/xi/XI/SplitAndMerge">
   <ns0:Message1>
      <ns1:MT_SPLIT xmlns:ns1="http://test.com">
         <PAYLOAD>
            <B001>
               <PAYLOAD1>
                  <KEY1>K1A</KEY1> 
                  <VALUE>V1A</VALUE> 
               </PAYLOAD1>
            </B001>
         </PAYLOAD>
      </ns1:MT_SPLIT>
      <ns1:MT_SPLIT xmlns:ns1="http://test.com">
         <PAYLOAD>
            <B001>
               <PAYLOAD1>
                  <KEY1>K1B</KEY1> 
                  <VALUE>V1B</VALUE> 
               </PAYLOAD1>
            </B001>
         </PAYLOAD>
      </ns1:MT_SPLIT>
      <ns1:MT_SPLIT xmlns:ns1="http://test.com">
         <PAYLOAD>
            <B002>
               <PAYLOAD2>
                  <KEY2>K2A</KEY2> 
                  <VALUE>V2A</VALUE> 
               </PAYLOAD2>
            </B002>
         </PAYLOAD>
      </ns1:MT_SPLIT>
      <ns1:MT_SPLIT xmlns:ns1="http://test.com">
         <PAYLOAD>
            <B002>
               <PAYLOAD2>
                  <KEY2>K2B</KEY2> 
                  <VALUE>V2B</VALUE> 
               </PAYLOAD2>
            </B002>
         </PAYLOAD>
      </ns1:MT_SPLIT>
      <ns1:MT_SPLIT xmlns:ns1="http://test.com">
         <PAYLOAD>
            <B002>
               <PAYLOAD2>
                  <KEY2>K2C</KEY2> 
                  <VALUE>V2C</VALUE> 
               </PAYLOAD2>
            </B002>
         </PAYLOAD>
      </ns1:MT_SPLIT>
  </ns0:Message1>
</ns0:Messages>

Does anyone suggest me some ideas?

Thanks in advance,

Gianluca

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

u can do 1 to 1 mapping for all the fields and node except MT_SPLIT.

for MT_SPLIT use following mapping

VALUE (field from PAYLOAD1) --> RemoveContext --> MT_SPLIT.

but do 1 to 1 mapping for all other nodes.

Regards,

Rohit

Reward points if helpful

Former Member
0 Kudos

I'm sorry but no one of your suggestion works. The last one produces only 1 MT_SPLIT:

<?xml version="1.0" encoding="UTF-8" ?> 
<ns0:Messages xmlns:ns0="http://sap.com/xi/XI/SplitAndMerge">
   <ns0:Message1>
      <ns1:MT_SPLIT xmlns:ns1="http://test.com">
         <PAYLOAD>
            <B001>
               <PAYLOAD1>
                  <KEY1>K1A</KEY1> 
                  <VALUE>V1A</VALUE> 
               </PAYLOAD1>
            </B001>
            <B001>
               <PAYLOAD1>
                  <KEY1>K1B</KEY1> 
                  <VALUE>V1B</VALUE> 
               </PAYLOAD1>
            </B001>
            <B002>
               <PAYLOAD2>
                  <KEY2>K2A</KEY2> 
                  <VALUE>V2A</VALUE> 
               </PAYLOAD2>
            </B002>
            <B002>
               <PAYLOAD2>
                  <KEY2>K2B</KEY2> 
                  <VALUE>V2B</VALUE> 
               </PAYLOAD2>
            </B002>
            <B002>
               <PAYLOAD2>
                  <KEY2>K2C</KEY2> 
                  <VALUE>V2C</VALUE> 
               </PAYLOAD2>
            </B002>
         </PAYLOAD>
      </ns1:MT_SPLIT>
  </ns0:Message1>
</ns0:Messages>

Former Member
0 Kudos

I have realized the generation of N MT_SPLIT instances by a UDF. The issue now is that only the B001 payload is rightly assigned, but not B002. My need is only one B00 payload par MT_SPLIT message*.

In fact I have mapped B001:

KEY1 (MT_SPLIT context) --> SplitByValue --> exists --> createif --> B001

The Result is this:

<?xml version="1.0" encoding="UTF-8" ?> 
<ns0:Messages xmlns:ns0="http://sap.com/xi/XI/SplitAndMerge">
   <ns0:Message1>
      <ns1:MT_SPLIT xmlns:ns1="http://test.com">
         <PAYLOAD>
            <B001>
               <PAYLOAD1>
                  <KEY1>K1A</KEY1> 
                  <VALUE>V1A</VALUE> 
               </PAYLOAD1>
            </B001>
         </PAYLOAD>
      </ns1:MT_SPLIT>
      <ns1:MT_SPLIT xmlns:ns1="http://test.com">
         <PAYLOAD>
            <B001>
               <PAYLOAD1>
                  <KEY1>K1B</KEY1> 
                  <VALUE>V1B</VALUE> 
               </PAYLOAD1>
            </B001>
         </PAYLOAD>
      </ns1:MT_SPLIT>
      <ns1:MT_SPLIT xmlns:ns1="http://test.com">
         <PAYLOAD>
         </PAYLOAD>
      </ns1:MT_SPLIT>
      <ns1:MT_SPLIT xmlns:ns1="http://test.com">
         <PAYLOAD>
         </PAYLOAD>
      </ns1:MT_SPLIT>
      <ns1:MT_SPLIT xmlns:ns1="http://test.com">
         <PAYLOAD>
         </PAYLOAD>
      </ns1:MT_SPLIT>
  </ns0:Message1>
</ns0:Messages>

Former Member
0 Kudos

Hi Gianluca,

You don't need an UDF to do this.

Just try this:

Create 2 nodes for your MT using Duplicate subtree.

In your first subtree, disable B002 and in second disable B001.

Now for your first sub tree

B001 -> removeContext -> MT

B001 -> copyValue -> PAYLOAD

B001-> copyValue -> B001

B001 -> copyValue -> PAYLOAD1

KEY1 -> KEY1

VALUE -> VALUE

Similarly, for your second subtree.

B002 -> removeContext -> MT

B002 -> copyValue -> PAYLOAD

B002-> copyValue -> B002

B002 -> copyValue -> PAYLOAD2

KEY2 -> KEY2

VALUE -> VALUE.

Regards,

Anirudh.

Former Member
0 Kudos

Thank you Anirudh. It works fine!

Best Regards,

Gianluca

Answers (3)

Answers (3)

former_member193376
Active Contributor
0 Kudos

Hi

This should work for you.

Duplicate subtree MT_SPLIT

for the first MT_SPLIT

B001 -> MT_SPLIT

constant -> B001

payload1->payload1

key1->key1

value->value

for the second MT_SPLIT

B002 -> MT_SPLIT

constant -> B001

payload2->payload2

key2->key2

value->value

Thanks

Saiyog

Former Member
0 Kudos

BOO1->EXISTS->IF THEN -> RemoveContext-> CollapseContext->SplitByValue->ns1:MT_SPLIT

BOO2->EXISTS->IF THEN -> RemoveContext-> CollapseContext->SplitByValue->ns1:MT_SPLIT

payload->payload

payload1->payload1

key1->key1

value->value

payload2->payload2

key2->key2

value->value

Former Member
0 Kudos

Hi Gianluca ,

if the amount of target messages is not clear, you have to use java mapping.

Regards Mario

Former Member
0 Kudos

Hi Mario,

Java Mapping it's not a good choice because we have to manage very big messages. So I would use Message Mapping (also with some UDF).