cancel
Showing results for 
Search instead for 
Did you mean: 

Using useOneAsMany function in Message Mapping if subtree is optional

Former Member
0 Kudos

Hi,

I am trying to develop a message mapping for the following case:

  • In the source message, there is a value "Value1" which is on the same level as a subtree "Struct2" which can occur 0..unbound times
  • In the target message the value "Value1" has to be part of that subtree, so it has to be copied for each occurence of "Struct2" in the source message

For the case that the subtree has cardinality 1..n there are some examples on the web, e.g. useOneAsMany (SAP-Bibliothek - Partner Connectivity Kit). But that does not fit my case. The subtree in the source message is optional here.

See a screenshot of the message mapping and my solution for the mapping of "Value1" below:

All other values are mapped 1:1.

Sadly, this solution does not work when "Struct2" has cardinality 0..unbound, for 1..unbound it works perfectly. Here is my example:

When I try the mapping, I get the following error message:

That is true. The first queue of the useOneAsMany function has more values than the second. But I don't know how I can fix it, so that it works for my example. Can anyone give me a hint please?

Setup is AEX 7.31.

Accepted Solutions (1)

Accepted Solutions (1)

former_member184720
Active Contributor
0 Kudos

Your mapping does't look correct to me.. for use one as many you should raise the context level

Former Member
0 Kudos

Thanks for your reply. The only difference I see in your solution is the additional "splitByValue" function. Why did you place it there?

I further simplified the example:

Now I get the error that the fist list has fewer context elements than the second. I used the following test data:

Why does it work in your example? I don't see the difference.

former_member184720
Active Contributor
0 Kudos

Hi - you should use remove context after Value2 or raise context (in the mapping area - right click on Value2 and choose Struct1 - this is what i did)

or

map the Struct2 segment to use one as many..(to both second and third parameters..)

markangelo_dihiansan
Active Contributor
0 Kudos

Hi Stefan,

You can use this mapping.

And for Struct2-Value1

Result:

Hope this helps,

Mark

Former Member
0 Kudos

Thank you, both solutions

  1. oneAsMany -> removeContext -> splitByValue
  2. concat -> splitByValue

work!

Former Member
0 Kudos

This also works. I didn't recognize you raised the context for var2. It is also possible to use Struct2 instead of var2. Thanks.

former_member184720
Active Contributor
0 Kudos

Hi Stefan - Can you please close the thread as the issue has resolved now..

Answers (1)

Answers (1)

Former Member
0 Kudos

@Hareesh,

I think ur mapping will throw error in case there is one more "Struct1" node (in ur screenshot Header) having "Struct2" (item) nodes

@Stefan,

Use below mapping for Field1 (here "str" means "struct2")

Thanks

Amit Srivastava

former_member184720
Active Contributor
0 Kudos

agreed.. just tested for the provided case.. just need to add a remove context..