cancel
Showing results for 
Search instead for 
Did you mean: 

Problem in Message Splitting

Former Member
0 Kudos

Hi All,

I have the following message structure

Source:

-


<messsage>

<header>

m

c

</header>

</message>

For each element under the header ,a seperate target tab " subject" should be generated.

Desired Target structure:

<message>

<Header>

<sub>

m

maths(constant)

</sub>

<sub>

c

chemistry(constant)

</sub>

</Header>

</Message>

Can somebody help me out in this mapping.

Thanks.

Sudha.

Accepted Solutions (1)

Accepted Solutions (1)

bhavesh_kantilal
Active Contributor
0 Kudos

Hi Sudha,

Your source cannot be created in the format that you want. You can explore any of this tow formats,

<message> <message>

<header> 1... UB <header> m </header>

</header> <header> c </header>

</message> </message>

or,

<message>

<header>

<elem> m </elem>

<elem> c </elem>

</header>

<message>.

Once your create your source of any ofthe above 2 formats, the mapping will be easy.

Do let me know if you have any further clarifications,

Hope this helps,

regards,

bhavesh

Former Member
0 Kudos

Hi Bhavesh,

thnaks for the response. the problem is the occurence of the header is 1.m and c are seperate elements under the header.

None of the source fields have multiple instances(occurences).

Thanks.

Sudha.

Former Member
0 Kudos

Hi Sudha

Could you give exact source data type?

Either you should have knowledge that element is going to occur some static numbers or it should be unbounded.

Your source data type should be

Header 1:1

Element 1:un (or 0:un)

Regards

Piuysh

Message was edited by: Piyush Gangwal

bhavesh_kantilal
Active Contributor
0 Kudos

Hi Sudha,

I still am not clear not the exact structure of your source and destination. Can you give a more precise example so that it will help us understand it better.

thanks and regards,

bhavesh

bhavesh_kantilal
Active Contributor
0 Kudos

Hi Sudha,

One solution for this canbe as follows if you are using SP14.

Sp14 allows you to use the concept pf global variables. So, you can use a Global variable that will contain if the value is 'c' or 'm' and you can write an userdefinde function that will look into the value of this global variable and return the coresponding constant "MATHS", "CHEMISTry", etc.

Check this link out for the GLOBAL VARIABLES,

/people/sap.user72/blog/2005/10/01/xi-new-features-in-sp14

hope this helps,

regards,

bhavesh

Message was edited by: Bhavesh Kantilal

Former Member
0 Kudos

Hi Piyush,

Thanks for the continious efforts. here is the exact structure,

Source:

salesorder --- 1

header --- 1

soldtoparty(0-1)

shiptoparty(0-1)

billtoparty(0-1)

payer (0-1)

Desired Target Structure:

salesorder

Partners(0-1)

partner(0-4)

partnerfunctio(0-1)

partnernumber (0-1)

Example instance;

source:

<saleesorder>

<header>

<soldtoparty>3000</soldtoparty>

<shiptotoparty>3100</shiptotoparty>

</header>

</salesorder>

Desired target:

<salesorder>

<partners>

<partner>

<partnerfunction>sp</partnerfunction>

<partnernumber>3000</partnernumber>

</partner>

<partner>

<partnerfunction>sh</partnerfunction>

<partnernumber>3100</partnernumber>

</partner>

</partners>

,/salesorder>

Thanks.

sudha.

Former Member
0 Kudos

Hi Bhavesh and Piyush,

Hi Piyush,

Thanks for the continious efforts. here is the exact structure,

Source:

salesorder --- 1

header --- 1

soldtoparty(0-1)

shiptoparty(0-1)

billtoparty(0-1)

payer (0-1)

Desired Target Structure:

salesorder

Partners(0-1)

partner(0-4)

partnerfunctio(0-1)

partnernumber (0-1)

Example instance;

source:

<saleesorder>

<header>

<soldtoparty>3000</soldtoparty>

<shiptotoparty>3100</shiptotoparty>

</header>

</salesorder>

Desired target:

<salesorder>

<partners>

<partner>

<partnerfunction>sp</partnerfunction>

<partnernumber>3000</partnernumber>

</partner>

<partner>

<partnerfunction>sh</partnerfunction>

<partnernumber>3100</partnernumber>

</partner>

</partners>

,/salesorder>

Thanks.

sudha.

Former Member
0 Kudos

Hi Sudha,

i did go through the source and target structure.for doing the same i would suggest you to use xslt mapping or java mapping.if you use either of the two it will be very easy for you to get the required target structure from your source structure.

Regards,

abhy

Former Member
0 Kudos

Hi Sudha,

With the help of UserDefined Functions, you can easily achieve this.

There will be 3 inputs like soldtoparty,shiptoparty,billtoparty.

You just have a "exists"

soldtopart--exists-userdefinedfn-----partner

shiptopart----exists-

billtopart----exists-

userdefined unction as

if(a[0].equals("true")){

result.addValue("sp");}

if(b[0].equals("true"))

result.addValue("sh");

if(c[0].equals("true"))

result.addValue("bp");

This will help you to achieve occurence of partner in target.

And generate the value for partnerfunction.

Just use split by value infront of this user defined function and map to partner function.

And for the partner no just use 6 input user defined function,

if(a[0].equals("true")){

result.addValue(d[0]);}

if(b[0].equals("true"))

result.addValue(e[0]);

if(c[0].equals("true"))

result.addValue(f[0]);

I hope you have got what you desire.

Cheers

Piyush

Former Member
0 Kudos

Hi Sudha,

There are two ways to proceed with this

<i>1.User defiend function</i>

a.header->user defined func->partner

User defined function

input(sold,ship,bill,payer)

if(!(a.length==0))

result.addValue(a[0]);

same for other three inputs)

b.header->user defined func->partfunc

if(!(a.length==0))

result.addValue("sp");

same for other three inputs

2.<i>Duplicate the target partner field 4 times</i>(since occurence is 0 to 4).

now

<b>sold->exists->createIf->partner</b>

<b>ship->exists->createIf->partner</b>

same for the rest.

user-defiend function (b) given above for partfunction

Cheers,

Rashmi

Former Member
0 Kudos

Hi Piyush,

Thanks a lot for your help. your code gave me the exact solution.I was struggling with this for two days and infact I had two transformations in my bpm to achieve this.

I have no words to express my joy. thanks a lot for spending your precious time.

Thanks.

Sudha.

Former Member
0 Kudos

Hi Rashmi,

Thanks a lot for your help. I tried piyush's code before trying yours and it worked perfect for me.

I beleive that your code works fine too.

Thanks.

Sudha.

Former Member
0 Kudos

Hi Sudha,

That's great.

I am feeling very happy that i and Bhavesh has solved your issue.

If you are intrested in friendship, my id is

gangwal.piyush@gmail.com

Regards

Piyush

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Sudha,

One important thing this is not message splitting. Since as par your requirement speified. this doesnot require message splitting.

Please explain the desired output structure.

As if you want maths followed by m in single element then you have to use Concate function.

But i don't think you require this.

And if you require maths followed by m in different elements then you have to use element for holding the value m and maths.

In this case your output structure will be

<Header>

<sub>

<ele>m</ele>

<ele>maths</ele>

</sub>

<sub>

<ele>c</ele>

<ele>chemitry</ele>

</sub>

</Header>.

Pleae clarify what do you want.

Regards

Piyush

Former Member
0 Kudos

Hi Piyush,

Thanks for the response. yes Piyush the target structure looks exactly the same like how you mentioned.

but my problem is, the header has an occurence of 1 and for each elements under it ( m and c ) , i have to produce <sub>.

thanks.

Sudha.

Former Member
0 Kudos

Hi if you want that target structure.

Then your input data type should be

header 1:1

Elemen 0:un

And mapping stuff

During mapping Element -


Sub

and with the help of fix value mapping, you can get constant value for each occurence of Element.So you will sub for every occurence of element like m,c,....

So

Element--


UserDefinedFunction---ele

Element-fixValue----

User defined function as

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

{

result.addValue(a<i>);

result.addValue(b<i>);

result.addValue(result.CC);

}

I hope this will serve the issue.

regards

Piyush