cancel
Showing results for 
Search instead for 
Did you mean: 

Graphical message mapping n to 1

Former Member
0 Kudos

Hi,

i need to merge multiple "rows" into one single row and want to know if there is a possibility to do this with a graphical mapping.

To elaborate my problem, here is an example of what i need to do:

Origin XML structure looks like this:

<root>
	<item>
		<tag1>A</tag1>
		<tag2>B</tag2>
	</item>
	<item>
		<tag1>C</tag1>
		<tag2>D</tag2>
	</item>
	...
</root>

and the target structure should be:

<root>
	<text>ABCD...</text>
</root>

To get one item into this "simple" structure is no problem. But how do i build something like a "for each item do".

I sure could build a java mapping, but i want to know if this problem can be solved using XIs grapfical mapping.

I really would appreciate any help.

Regards,

Benjamin

Accepted Solutions (1)

Accepted Solutions (1)

SudhirT
Active Contributor
0 Kudos

Hi ,

I think you can write one udf which will contain a loop for the no. of occurence of items and the inputs will be tag1 and tag2 value of each occurence and keep on appending the tag1 and tag2 values.

Thanks!

Former Member
0 Kudos

Hi,

i went through all the linked blogs, but i still dont get it.

I made a screenshot of my Message Mapping:

[n:1 problem|http://img222.imageshack.us/img222/2838/1tonlf4.jpg]

Pay attention to the red marked occurrences. Can someone please explaine me, how exactly my mapping has to look, so that multiple "row"s get merged into one single "text".

If there is no way to do that with the graphical mapping i am also fine with that. Then i write a java mapping. But if it is possible i would prefer the graphical way.

Thanks alot in advance.

Former Member
0 Kudos

Hi Benjamin,

I think you could do something like that.

Remove all the change contexts in Char1 and Char2 nodes. The result should be two queues. One of them belongs to Char1 node and the other one belongs to Char2 node. Both of them must be with change contexts.

Fed an advanced user defined function with Char1 and Char2.

The code must be something lik.

String Resulttext,Resulttext2

(for int i=0; i < Char1.length; i++)

{

Resulttext = Concat (Char1[0], Char2[0]);

Resultext2= Concat (Resultext2, Resulttext);

}

result.addValue (Resulttext2)

Hope this help you,

Carlos

Answers (8)

Answers (8)

former_member192295
Active Contributor
0 Kudos

Hi,

It is possible in graphics mapping through UDF function. according to ur requirement develop one simple UDF and put logic for concatenate all source string into one and transfer to receiver, it will sort out easily.

Former Member
0 Kudos

Hi,

thanks again to all trying to help me.

How exactly do i create the loop over the "row"s?

I think i got the rest. I'll use an UDF for that.

regards,

Benjamin

Former Member
0 Kudos

as both are form different contexts i think you have to use removecontext

dharamveer_gaur2
Active Contributor
0 Kudos

hi read below SAP documentation,your problem would be solve

useOneAsMany node function with concat for N:1

usedetail:http://help.sap.com/saphelp_nw04/helpdata/en/ef/df564b6aa24fc9ab0d685460747de5/content.htm

Edited by: Dharamveer Gaur on Sep 17, 2008 9:04 AM

Former Member
0 Kudos

Hi Benjamin

You can get this by using Concate function.

use logic like text = (ABC+D)

which can be achived by (((AB)C)+D)

Hope u got it.

Regards

Raj

dharamveer_gaur2
Active Contributor
0 Kudos

use this funciton.

node function useOneAsMany

use of thisfunction:

Edited by: Dharamveer Gaur on Sep 17, 2008 8:49 AM

Former Member
0 Kudos

Well, first of all, thank you all for your quick responses.

But unfortunately nothing really solved my problem.

Of course i can use the function Concatenate to get the tags of ONE item into the desired output format, but how can i execute this concatenation multiple times (as often as item appears in the origin xml).

<root>
	<item>
		<tag1>A</tag1>
		<tag2>B</tag2>
	</item>
	<item>
		<tag1>C</tag1>
		<tag2>D</tag2>
	</item>
	...
</root>

With a mapping like this:

{tag1} --- {concatenate} --- {text}
{tag2} ---´

i can get an output like this:

<root>
	<text>AB</text>
</root>

But it does not concatenate all and tags of all items.

The first blog posted by Chetan is unfortunately exactly the wrong way: 1:n

But what i need is a n:1 mapping.

And if i am not wrong the function useOneAsMany is also for a 1:n mapping.

If i can solve my n:1 problem with that function too, i would appreciate a detailed explanation of how this works.

pradeep_nellore
Participant
0 Kudos

Yes , you can do this by function Concatenate avaialble in Graphical mapping.

dharamveer_gaur2
Active Contributor
0 Kudos

use this

Edited by: Dharamveer Gaur on Sep 17, 2008 8:34 AM

Former Member
0 Kudos

Hi

check the below mentioned link and i hope your problem will be resolved .

Regard's

Chetan Ahuja

Edited by: Chetan Ahuja on Sep 17, 2008 8:26 AM