cancel
Showing results for 
Search instead for 
Did you mean: 

Message mapping issue

Former Member
0 Kudos

Hello,

I got the following structure:


<ITEM_TAB>
  <item>
    <number>1</number>
  </item>
  <item>
    <number>2</number>
  </item>
</ITEM_TAB>
<ITEM_EXT>
  <item>
    <number>1</number>
    <tax_name>TAX 1 FOR ITEM 1</tax_name>
  </item>
  <item>
    <number>1</number>
    <tax_name>TAX 2 FOR ITEM 1</tax_name>
  </item>
  <item>
    <number>2</number>
    <tax_name>TAX 1 FOR ITEM 2</tax_name>
  </item>
  <item>
    <number>2</number>
    <tax_name>TAX 2 FOR ITEM 2</tax_name>
  </item>
</ITEM_EXT>

And I need to get the following XML:


<ITEM_OUT>
  <item>
    <number>1</number>
    <tax_name1>TAX 1 FOR ITEM 1</tax_name1>
    <tax_name2>TAX 2 FOR ITEM 1</tax_name2>
 <item>
 <item>
    <number>2</number>
    <tax_name1>TAX 1 FOR ITEM 2</tax_name1>
    <tax_name2>TAX 2 FOR ITEM 2</tax_name2>
 <item>
</ITEM_OUT>

It's possible to do this using message mapping ? If not what you suggest me?

Regards.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi !

Yes, it is possible with graphical message mapping.

You have plenty of examples in the TBIT41 under mapping concepts. Specially under context mapping examples.

Regards,

Matias.

Former Member
0 Kudos

Hello,

Unfortunately I don't have access to the TBIT41 documentation, can you give some example, please?

Regards.

Former Member
0 Kudos

Hi !

First of all, you will need to make a little change in the output format...

it should be something like:

<ITEM_OUT>
      <item>
         <number>1</number>
         <tax_names>
            <tax_name>tax 1 for 1</tax_name>
            <tax_name>tax 2 for 1</tax_name>
            <tax_name>tax 3 for 1</tax_name>
         </tax_names>
      </item>
      <item>
         <number>2</number>
         <tax_names>
            <tax_name>tax 1 for 2</tax_name>
            <tax_name>tax 2 for 2</tax_name>
         </tax_names>
      </item>
   </ITEM_OUT>

see that you are not able to generate "tax_name1" "tax_name2" dinamically, and for creating multiple tax_name items you need a complex-element (tax_names) to be the parent.

Then, the mapping could be like this:

/ns0:mt_items_target=/ns0:mt_items=

/ns0:mt_items_target/ITEM_OUT=/ns0:mt_items/ITEM_EXT=

/ns0:mt_items_target/ITEM_OUT/item=/ns0:mt_items/ITEM_TAB/item=

/ns0:mt_items_target/ITEM_OUT/item/number=/ns0:mt_items/ITEM_TAB/item/number=

/ns0:mt_items_target/ITEM_OUT/item/tax_names/tax_name=my_function(SplitByValue([type=Value changed]removeContexts(/ns0:mt_items/ITEM_EXT/item/number=)), removeContexts(/ns0:mt_items/ITEM_EXT/item/tax_name=))

where "my_function" is an advanced (queue) user defined function:

int h=0;
for (int i=0;i<a.length;i++){
     if (a<i>.equals(ResultList.CC))
          result.addValue(ResultList.CC);
     else
     {
         result.addValue(b[h]);
         h++;
     }
}

This function receives 2 parameters ("a" and "b" string arrays), the number value queue (param "a") and the tax_name value queue (param "b"), and outputs the tax_name value queue using the context changes of the number value queue.

I've tried and it works.

Regards,

Matias.

Edited by: Matias Denker on Sep 3, 2008 5:57 PM

Former Member
0 Kudos

Hello,

Thank you to everybody.

I follow the solution proposed by Matias and solved my problem.

Regards.

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi David,

You can use Java Mapping.

rgds.