cancel
Showing results for 
Search instead for 
Did you mean: 

Message Mapping

Former Member
0 Kudos

Hi,

I have some problem with a Message mapping.

I have n elements in the source strukture.

For each of them i want to create 3 of the same elements in the target structure.

i can do this when i duplicate the target tree three times. But that's isn't that what i want.

Because i have bulid a customer function as counter.

And i want that the counter counts first the 3 segments for my first source segment... (no1 - no3) ... than for my seconde source segment (no4-no6) and so on.

But what he is doing is first create all the first target segments for the n elements in the source structure. Than the second target segments for the n elment.. and so on. And this way the counter isn't counting like i want.

I hope you can understand what i want.

Here an example:

source i have:


<main>
 <row>
  <name1>Paul</name1>
  <name2>Peter</name2>
  <name3>Julia</name3>
 <row> 
 <row>
  <name1>Emma<name1>
  <name2>Vikki</name2>
  <name3>Angie</name3>
 <row> 
</main>

target i want:


<main>
  <row>
   <no>1</no>
   <name>Paul</name>
  <row>
  <row>
   <no>2</no>
   <name>Peter</name>
  <row>
  <row>
   <no>3</no>
   <name>Julia</name>
  <row>
  <row>
   <no>4</no>
   <name>Emma</name>
  <row>
  .....
</main>

Regards,

Robin

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

--for each source row i have to create 11 target rows.

Sure! count of target row is the count of all name1..name3 from source

This means that the Output Queue from target row must have (11) values

--And in this target rows i have to map in all 11 different fields from the one source --row.

Sure with step one you will create 11 rows with one name field and one number field. The right order is now given by the queue input.

You need 11 values to get the names with context change to jump into the next row element. Also the counter will work.

--I guess your way is the right to do that ...

--no i just have to now how to extend --you example.

Sorry my English is not so well what will you extend. This works.

i dublicated the input row node in my test:

<?xml version="1.0" encoding="UTF-8"?>

<ns0:Target xmlns:ns0="urn:altanapharma.com:bapi:620:z_bapi_requisition_create"><row><no>1</no><name>paul</name></row><row><no>2</no><name>peter</name></row><row><no>3</no><name>julia</name></row><row><no>4</no><name>emma</name></row><row><no>5</no><name>vikk</name></row><row><no>6</no><name>jueng</name></row><row><no>7</no><name>emma</name></row><row><no>8</no><name>vikk</name></row><row><no>9</no><name>jueng</name></row><row><no>10</no><name>emma</name></row><row><no>11</no><name>vikk</name></row><row><no>12</no><name>jueng</name></row><row><no>13</no><name>emmawww</name></row><row><no>14</no><name>vikkwww</name></row><row><no>15</no><name>juengww</name></row></ns0:Target>

Daniel

Former Member
0 Kudos

Hi,

i start now to do following.

I have for the row tag one customer function which create 11 tags for me.

And for each field in the the target row i will build a customer function which create a que with 11 entrys.

some field from the source row >CustomerFunction(11entry queue)> remove Context--> row

Counter --> NO

different fields with the possilbe values depends on the target row -->CustomerFunction1(11entry queue) --> value01

different fields with the possilbe values depends on the target row -->CustomerFunction2(11entry queue) --> value02

I hope this will work.

Regards,

Robin

Former Member
0 Kudos

Hi

You can implement this without UDF using Standard Functions.

Creation of output structure depends on the example given in question.

1)row in the target can be mapped to name with context changed to main(default it is in row context).

2)You just try to do as following to generate counter:

1)name with context changed to main .

2)use Statistics index.

3)use splitByValue.

4)mapped to number.

3)For name just use SplitByValue will work.

Thanks and Regards,

Vineetha

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi Robin,

I was able to rebuild your scenario.

The most important thing is how create the queue for target name field.

I wrote a short function (type context)

3 input parameters and one output resultset

- - -

result.addValue(a[0]);

result.addContextChange();

result.addValue(b[0]);

result.addContextChange();

result.addValue(c[0]);

- -

source

<row>

<name1>

<name2>

<name3>

target

<row>

<no>

<name>

Mapping

Name1 name 2 name3 into function -- > removeContext -- > ROW

Counter - - > NO

Name1 name 2 name3 into function - - > NAME

This works. The answer of good mapping is in the queue handling !!!

Daniel

Former Member
0 Kudos

Hi,

This works for a simple szenario.

But in my case i need a little bit more.

for each source row i have to create 11 target rows.

And in this target rows i have to map in all 11 different fields from the one source row.

I guess your way is the right to do that ... no i just have to now how to extend you example.

Am i right when i say i have to write a user defined function for each field in the target structure?

Regards,

Robin

Former Member
0 Kudos

hi Robin,

In your mapping , an easy solution could be to use the option "<b>Duplicate Subtree</b>" (see contextual menu) on your target <row>. Use this option for each source <nameN>.

Do not forget that you have a fixed numbers source <nameN> because you have to create a source Data Type with a all fields <nameN>:

<row>

<name<b>1</b>></name1>

<name<b>2</b>></name2>

<name<b>3</b>></name3>

...

<row>

Thus after that, just link:

<name1> to 1st <name> with a simple user-defined function to increment a global variable for your target <no>

<name2> to 2nd <name> with a simple user-defined function to increment a global variable for your target <no>

<name3> to 3rd <name> with a simple user-defined function to increment a global variable for your target <no>

etc...

For your target <no>, you can create a simple User-defined function which get the result of your global variable.

Hope this help you

Mickael

P.S: <i>About the user-defined fonction to manage a "counter", I forecast to create weblog in next days.</i>

Former Member
0 Kudos

Hi,

the function i have already

GlobalContainer globalContainer = container.getGlobalContainer();
Object o = globalContainer.getParameter("counter");
Integer ii;
if(o== null ) ii= new Integer(0);
else ii =(Integer)o;
ii= new Integer (ii.intValue() + 1 );
globalContainer.setParameter("counter", ii);
return ii.toString();

that's not the problem.

And i use a well the duplicate Subtree.

But the catch is that he first create the target structure for each row in the source.

Than the same again for the duplicated.

So when i have 3 rows in the source i have follwing target.

<row>my counter = 1</row>

<row>my counter = 2</row>

<row>my counter = 3</row>

<duplicaterow>my counter = 4</duplicaterow>

<duplicaterow>my counter = 5</duplicaterow>

<duplicaterow>my counter = 6</duplicaterow>

but it should be

<row>my counter = 1</row>

<duplicaterow>my counter = 2</duplicaterow>

<row>my counter = 3</row>

<duplicaterow>my counter = 4</duplicaterow>

Regards,

robin

Former Member
0 Kudos

Hi Robin,

Maybe I didn't understand. Where do you want to have a counter? is it on your target <no>? If yes, it's easy... if you have SP13 or higher.

target :

<main>

<row>

<no>1</no>

<name>Paul</name>

<row>

<row>

<no>2</no>

<name>Peter</name>

<row>

</main>

Message was edited by:

Mickael Huchet

Former Member
0 Kudos

Hi,

its hard to explain ... but i think it is not so easy.

from one row in soure i want to create 3 in target.

            
            rowA (counter 1)
rowA--------rowA (counter 2)
            rowA (counter 3)

            rowB (counter 4)
rowB--------rowB (counter 5)
            rowB (counter 6)

in the rows are different field i want map 1:1.

So i duplicate the row in the target 3 times.

But when running the mapping he is not doing it like you say.

He us doing following


rowA --- rowA(counter 1)
rowB --- rowB(counter 2)
rowA --- rowA(counter 3)
rowB --- rowB(counter 4)
rowA --- rowA(counter 5)
rowB --- rowB(counter 6)

rowA and rowB have normally the same name... just make the A and B that you see which content of the segments he map.

Jesus is really hard to explain... i hope you see the point. The mapping go throw the target structure and looks how often the segments must created .. and on each create he count.

Maybe i make something simple wrong why he doing this way.

Regards,

Robin

former_member184619
Active Contributor
0 Kudos

hi Robin,

just check this

/people/stefan.grube/blog/2005/12/29/new-functions-in-the-graphical-mapping-tool-xi-30-sp13

<b>INDEX function.</b>

and also try out counter function

http://help.sap.com/saphelp_nw2004s/helpdata/en/2c/2d8c4024d26e1de10000000a1550b0/frameset.htm

Regards

Sachin

Message was edited by:

Sachin Dhingra

Former Member
0 Kudos

Hi,

Try using Index with context being Row and not hte entire document

Regards

vijaya

Former Member
0 Kudos

Hi Robin,

You could use a user-defined function, which gets the current count from the container (or "0" if there is none yet), increments it, saves it back and returns the value.

Kind regards,

Dennis

Former Member
0 Kudos

Hi,

i have already this function ... and it works fine the counting.

But as i said it counts wrong, because he first map all source segments.

based on my example i get right now follwoing structure:


<main>
  <row>
   <no>1</no>
   <name>Paul</name>
  <row>
  <row>
   <no>2</no>
   <name>Emma</name>
  <row>
  <row>
   <no>3</no>
   <name>Peter</name>
  <row>
  <row>
   <no>4</no>
   <name>Vikki</name>
  <row>
  .....
</main>

thats wrong...

I will test the index function ... but it looks like index repeats counting for each context. I Don't want that.

regards,

Robin