cancel
Showing results for 
Search instead for 
Did you mean: 

Field dependent message split

Former Member
0 Kudos

HI

I need to split a message according to the content of one

element that occurs in each of n structures. The message looks as follows_

<Root>

---<Structure> (Occurs 0..n)

-


<ElementX> (Occurs 1..1)

-> Possible values are X, Y or Z <i>(values are unknown and have a quantity of 1..n)</i>

-


<ElementZ> (Occurs 1..1)

And I need to aquier the following messages:

<Root>

---<Structure> (Occurs 0..n)

-


<ElementX> (Occurs 1..1)

-> Value X

-


<ElementZ> (Occurs 1..1)

<Root>

---<Structure> (Occurs 0..n)

-


<ElementX> (Occurs 1..1)

-> Value Y

-


<ElementZ> (Occurs 1..1)

<Root>

---<Structure> (Occurs 0..n)

-


<ElementX> (Occurs 1..1)

-> Value Z

-


<ElementZ> (Occurs 1..1)

Anybody got an idea?

Thanks,

Nana

Message was edited by: Nana Lohmanns

Message was edited by: Nana Lohmanns

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Please try the following:

<b>Source Structure 1:</b>

<ROOT>(1..1)

---<INPUT>(0..UNBOUND)

-


<FIELD_X_Y_Z>(1..1)

-


<FIELD_OTHER>(1..1)

<b>

Target Structure 1: </b>

<ROOT>(1..1)

---<OUTPUT>(0..UNBOUND)

-


<FIELD_X>(1..1)

-


<FIELD_OTHER>(1..1)

<b>Target Structure 2:</b>

<ROOT>(1..1)

---<OUTPUT>(0..UNBOUND)

-


<FIELD_Y>(1..1)

-


<FIELD_OTHER>(1..1)

<b>Target Structure 3:</b>

<ROOT>(1..1)

---<OUTPUT>(0..UNBOUND)

-


<FIELD_Z>(1..1)

-


<FIELD_OTHER>(1..1)

<b>Note:</b> you have to add these target struture in the messages tab in the message mapping

<b>Mapping:</b>

for target struture1(X):

FIELD_X_Y_Z(with context as ROOT)--\

-


|-->OUTPUT

-


constant(x)--/

FIELD_X_Y_Z(with context as INPUT)-->FIELD_X

FIELD_OTHER(with context as INPUT)-->FIELD_OTHER

for target struture2(Y):

FIELD_X_Y_Z(with context as ROOT)--\

-


|-->OUTPUT

-


constant(y)--/

FIELD_X_Y_Z(with context as INPUT)-->FIELD_X

FIELD_OTHER(with context as INPUT)-->FIELD_OTHER

for target struture3(Z):

FIELD_X_Y_Z(with context as ROOT)--\

-


|-->OUTPUT

-


constant(z)--/

FIELD_X_Y_Z(with context as INPUT)-->FIELD_X

FIELD_OTHER(with context as INPUT)-->FIELD_OTHER

<b>TestData:</b>

<b>Input:</b>

<ns0:Messages xmlns:ns0="http://sap.com/xi/XI/SplitAndMerge">

<ns0:Message1>

<ROOT>

<INPUT>

<FIELD_X_Y_Z>z</FIELD_X_Y_Z>

<FIELD_OTHER>1</FIELD_OTHER>

</INPUT>

<INPUT>

<FIELD_X_Y_Z>y</FIELD_X_Y_Z>

<FIELD_OTHER>2</FIELD_OTHER>

</INPUT>

<INPUT>

<FIELD_X_Y_Z>x</FIELD_X_Y_Z>

<FIELD_OTHER>3</FIELD_OTHER>

</INPUT>

<INPUT>

<FIELD_X_Y_Z>y</FIELD_X_Y_Z>

<FIELD_OTHER>4</FIELD_OTHER>

</INPUT>

</ROOT>

</ns0:Message1>

</ns0:Messages>

<b>Output:</b>

<ns0:Messages xmlns:ns0="http://sap.com/xi/XI/SplitAndMerge">

<ns0:Message1>

<ROOT>

<OUTPUT>

<FIELD_X>x</FIELD_X_Y_Z>

<FIELD_OTHER>3</FIELD_OTHER>

</OUTPUT>

</ROOT>

</ns0:Message1>

<ns0:Message2>

<ROOT>

<OUTPUT>

<FIELD_y>y</FIELD_X_Y_Z>

<FIELD_OTHER>2</FIELD_OTHER>

</OUTPUT>

<OUTPUT>

<FIELD_y>y</FIELD_X_Y_Z>

<FIELD_OTHER>4</FIELD_OTHER>

</OUTPUT>

</ROOT>

</ns0:Message2>

<ns0:Message3>

<ROOT>

<OUTPUT>

<FIELD_Z>z</FIELD_X_Y_Z>

<FIELD_OTHER>1</FIELD_OTHER>

</OUTPUT>

</ROOT>

</ns0:Message3>

</ns0:Messages>

Regards,

KNS Kumar.

Former Member
0 Kudos

Hi Kumar

First thanks for this detailed explanation however I am not sure if this solves the problem.

The constants that yhould be used for a message split are not only X,Y, and Z but a variable number of values unknown at design time. As such it is not possible to make a predesigned mapping based on constants.

I don't know how to approach it and I am really greateful for any help.

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi Nana,

If you plan to create some 10*6 datasets you should definitly not use ccBPM! Otherwise you risk to run into performance problems.

If you plan to use an adapter of the adapter engine at the receiving side, the split can also be executed in the adapter. Please check

<a href="http://help.sap.com/saphelp_nw04/helpdata/en/14/80243b4a66ae0ce10000000a11402f/frameset.htm">the online help</a> for further details.

The multi-mapping for this solution is similar to the one you'd need to set up for ccBPM. You just have to move the repeating element in your structure one level up in your structure hierarchy as explained in my previous posting.

Best regards

Joachim

Former Member
0 Kudos

Hi Nana,

If I got you right, your target interface looks always the same (i.e. your target message type is always the same)? Are all these messages intended to be sent to the samer receiver? Which adapter/proxy do you want to use on receiver side?

I'm asking these questions, since you do not forcedly require ccBPM to perform splits. I'd assume that you can simply set up a 1:n mapping (which is possible in some cases even without using ccBPM), where you do the following:

Structure -> Root
ElementX -> Structure
ElementX -> ElementX

Best regards

Joachim

Former Member
0 Kudos

Hi Joachim

The problem is that I need all structures containing a value X for ElementX combined in a separate message.

If I understand your example correctly then this would create a message for each structure, which is not what I want since we are talking about a few 10^6 datasets.

The core problem is how to split the messages according to a field and receive subsets of the message containing all structures in which the values of ElementX always equals each other.

Do you think this is possible with pure message mapping or do you think BPM is required?

Former Member
0 Kudos

Hi Nana,

This Could be what u are looking for:

Say u'r input is

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

<ns0:Messages xmlns:ns0="http://sap.com/xi/XI/SplitAndMerge">

<ns0:Message1>

<ROOT>

<Structure>

<ElementX>x</ElementX>

<ElementZ>1</ElementZ>

</Structure>

<Structure>

<ElementX>y</ElementX>

<ElementZ>2</ElementZ>

</Structure>

<Structure>

<ElementX>z</ElementX>

<ElementZ>3</ElementZ>

</Structure>

<Structure>

<ElementX>A</ElementX>

<ElementZ>7</ElementZ>

</Structure>

<Structure>

<ElementX>y</ElementX>

<ElementZ>4</ElementZ>

</Structure>

</ROOT>

</ns0:Message1>

</ns0:Messages>

Then out put should be 4 messages 1 for each x,y,a and Z. And message for Y should have 2 strutures as inpput has 2 structures with ElementX as 'y'

I.e. output is

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

<ns0:Messages xmlns:ns0="http://sap.com/xi/XI/SplitAndMerge">

<ns0:Message1>

<ROOT>

<Structure>

<ElementX>x</ElementX>

<ElementZ>1</ElementZ>

</Structure>

</ROOT>

<ROOT>

<Structure>

<ElementX>y</ElementX>

<ElementZ>2</ElementZ>

</Structure>

<Structure>

<ElementX>y</ElementX>

<ElementZ>4</ElementZ>

</Structure>

</ROOT>

<ROOT>

<Structure>

<ElementX>z</ElementX>

<ElementZ>3</ElementZ>

</Structure>

</ROOT>

</ns0:Message1>

</ns0:Messages>

if this is what u'r requirement is then do the mapping as below:

Mapping:

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

<ns0:Messages xmlns:ns0="http://sap.com/xi/XI/SplitAndMerge">

<ns0:Message1>

<ROOT>

<Structure>

<ElementX>x</ElementX>

<ElementZ>1</ElementZ>

</Structure>

<Structure>

<ElementX>y</ElementX>

<ElementZ>2</ElementZ>

</Structure>

<Structure>

<ElementX>z</ElementX>

<ElementZ>3</ElementZ>

</Structure>

<Structure>

<ElementX>A</ElementX>

<ElementZ>7</ElementZ>

</Structure>

<Structure>

<ElementX>y</ElementX>

<ElementZ>4</ElementZ>

</Structure>

</ROOT>

</ns0:Message1>

</ns0:Messages>

Then out put should be 4 messages 1 for each x,y,a and Z. And message for Y should have 2 strutures as inpput has 2 structures with ElementX as 'y'

I.e. output is

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

<ns0:Messages xmlns:ns0="http://sap.com/xi/XI/SplitAndMerge">

<ns0:Message1>

<ROOT>

<Structure>

<ElementX>x</ElementX>

<ElementZ>1</ElementZ>

</Structure>

</ROOT>

<ROOT>

<Structure>

<ElementX>y</ElementX>

<ElementZ>2</ElementZ>

</Structure>

<Structure>

<ElementX>y</ElementX>

<ElementZ>4</ElementZ>

</Structure>

</ROOT>

<ROOT>

<Structure>

<ElementX>z</ElementX>

<ElementZ>3</ElementZ>

</Structure>

</ROOT>

</ns0:Message1>

</ns0:Messages>

<b>Note:</b>Change the occurance of target message as o..unbounded in messagetab of mapping program.

Also have to change the occurance of message interface in interface mapping as 0..unbounded.

While doing interface determination you have to select extended.No need for BPM.

ElementX(with context ROOT)>SORT>SPLITBYVALUE(VALUECHANGED)>COLLAPSECONTEXT>ROOT

ElementX(with context ROOT)>SORT>SPLITBYVALUE(VALUECHANGED)-->STRUTURE

ElementX(with context ROOT)>SORT>SPLITBYVALUE(EACHVALUE)-->ElementX

ElementX(with context ROOT)--\

-


>SORTBYKEY>SPLITBYVALUE(EACHVALUE)>ElementX

ElementZ(with context ROOT)--/

Regards,

KNS Kumar.

Former Member
0 Kudos

Hi Kumar

This sounds exactly like what I am looking for, there is only one more thing.

Now if I understand your mapping correctly you refer to the values for <ElementX>, however these values are not known beforehand.

I want to use this mapping in several situations where the sets of <ElementX> may vary.

Is this possible with your idea?

Former Member
0 Kudos

Should work irrespective of values of ElementX

I said x,y,a z only for your understanding...

Why don't you try it with your test data so that you feel more confident....

Regards,

KNS Kumar.

STALANKI
Active Contributor
0 Kudos

Hi Nana,

If my understanding is right you need to initiate the structure node as many time as many values are there in the element X.

You can achieve it using two user defined functions.

1.MaptoStructure.

source code :

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

result.addValue("");

In the mapping map the element x to create that many structure nodes USING user defined function MaptoStructure

elementX->MaptoStructure->Structure(Target).

2.elementX(source)->elementX(Target).

Set the element context in step1 to root and second one should be to Structure.

Revert if u have problem even after that.

Former Member
0 Kudos

Hi,

You must use Multi-Mapping.

The target message should have occurence of 3.

use simple graphical mapping to select X,Y or Z for each target message.

hope this helps.

regards,

P.Venkat

Former Member
0 Kudos

Maybe I need to clarify a little bit.

First, I don't only have the values X, Y, and Z for the split but these values and quantities are undefined at design time.

Second, each of the new messages should contain 1..n structures each with the ElementX equal to the same value.

The point is the new messages should contain a subset of the structures (all structures with equal ElementX) previously held in the original message.

By the way, the link does not refer to message split but to the enhanced receiver determination, could you post the right link?

former_member187339
Active Contributor
0 Kudos

Hi,

Can you give an example for your source and target structure?

Is the structure same as given by kumar?

Regards

Suraj

Former Member
0 Kudos

Hi Nana,

Use multi mapping

Try this link. He has clearly explained how to do it.

/people/venkataramanan.parameswaran/blog/2006/03/17/illustration-of-enhanced-receiver-determination--sp16

Thanks and Regards

Vishal Kumar