cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping to multi-valued elements

Former Member
0 Kudos

Hello! I need to save business partner structure to CRM via IDOC.

So, I have Tax Numbers in source structure looks like:

<TaxNumbers>

<Numbers>CRM003, BBP000</Numbers>

</TaxNumbers>

And in IDOC there are one multi-valued element

<TaxNumbers> - occurrence is unbounded

<KEYS>...</KEYS>

<TaxNumbers>

So, could you help me how to develop mapping program in this case?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

UDF:

String[] b=a[0].split(",");

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

result.addValue(b<i>);

Map like below.

NumbersUDF-TaxNumbers(Target)

NumbersUDF-SplitByValue(EachValue)--KEYS

Regards,

Prakasu.M

Former Member
0 Kudos

Dear Prakasu, what should I define, when I create this new UDF ?

Shabarish_Nair
Active Contributor
0 Kudos

look at the link i provided.

it will help you create the UDF

Former Member
0 Kudos

Hi,

Creation of UDF select queue.Give any name for UDF.

Map like below.

Numbers(Change Context)UDF-TaxNumbers(Target)

Numbers(Change Context)--UDF-SplitByValue(EachValue)--KEYS

Change Context-Right click the Numbers and Change the context to parent node.

UDF- Which you created.

Regards,

Prakasu.M

Answers (5)

Answers (5)

Former Member
0 Kudos

Okey, it works. There was an error in code:

String[] b=a[0].split(",");

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

result.addValue(b);

Former Member
0 Kudos

So, now I have:

<TaxNumbers>

<Keys>[Ljava.lang.String;@165cd718</Keys>

</TaxNumbers>

<TaxNumbers>

<Keys>[Ljava.lang.String;@165cd718</Keys>

</TaxNumbers>

Former Member
0 Kudos

Try replacing

result.addValue(b);

with

result.addValue(b<i>);

Kind regards,

Koen

Former Member
0 Kudos

I have this errors:

Source text of object Message Mapping: mm_test1_to_test2 | http://test.mrcb.ru/1 has syntax errors:

Source code has syntax error: D:\usr\sap\P1D\DVEBMGS00\j2ee\cluster\server0\.\temp\classpath_resolver\Mapd5c1aa10243111deba85000c29aeb543\source\com\sap\xi\tf\_mm_test1_to_test2_.java:76: cannot find symbol symbol : class string location: class com.sap.xi.tf._mm_test1_to_test2_ string[] b=a[0].split(","); ^ D:\usr\sap\P1D\DVEBMGS00\j2ee\cluster\server0\.\temp\classpath_resolver\Mapd5c1aa10243111deba85000c29aeb543\source\com\sap\xi\tf\_mm_test1_to_test2_.java:76: array required, but java.lang.String found string[] b=a[0].split(","); ^ D:\usr\sap\P1D\DVEBMGS00\j2ee\cluster\server0\.\temp\classpath_resolver\Mapd5c1aa10243111deba85000c29aeb543\source\com\sap\xi\tf\_mm_test1_to_test2_.java:78: cannot find symbol symbol : variable result location: class com.sap.xi.tf._mm_test1_to_test2_ result.addValue(b<i>); ^ Note: D:\usr\sap\P1D\DVEBMGS00\j2ee\cluster\server0\.\temp\classpath_resolver\Mapd5c1aa10243111deba85000c29aeb543\source\com\sap\xi\tf\_mm_test1_to_test2_.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: D:\usr\sap\P1D\DVEBMGS00\j2ee\cluster\server0\.\temp\classpath_resolver\Mapd5c1aa10243111deba85000c29aeb543\source\com\sap\xi\tf\_mm_test1_to_test2_.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 3 errors

Former Member
0 Kudos

Andrey,

Java is case sensitive, you made a mistake in this line:

string[] b=a[0].split(",");

This should be

String[] b=a[0].split(",");

Kind regads,

Koen

Former Member
0 Kudos

Could you explain me in few words, how can I solve my problem?

Shabarish_Nair
Active Contributor
0 Kudos

<Numbers>CRM003, BBP000</Numbers>

split the value in the field - use an udf for this and write out each value as an entry in the resultset

the result can then be easily mapped to your target

Former Member
0 Kudos

In target structure I have only one element wich is unbounded, and how can I map two values to one?

Shabarish_Nair
Active Contributor
0 Kudos

an advance UDF will create context. You can map the output of the UDF to the root node of the target field also which is unbounded and it will take care of creating multiple occurrences.

In short you will handle both root node and field value mapping.

Advanced UDFs - http://help.sap.com/saphelp_nw04/helpdata/en/f8/2857cbc374da48993c8eb7d3c8c87a/content.htm