cancel
Showing results for 
Search instead for 
Did you mean: 

XI mapping Question

Former Member
0 Kudos

First I know the XML I post below is modeled incorrectly and the Werks field should be a repeating group. I am trying to solve the problem using the graphical mapping program to produce a split of werks by "," into a table modeled from a bapi.

I have tried all kinds of functions in the graphical editor and nothing seems to be able to produce the desired output.

Anyone have any ideas or experience with this type of mapping challenge?

Input:

<ns0:MT_MAT xmlns:ns0="urn:rfmd-com:AGILE_INTEGRATION-MAT_BOM">

<KEY/>

<MATNR>12345</MATNR>

<ACD>A</ACD>

<MTART/>

<WERKS>1200,1300</WERKS>

........

How would I get the mapping program to split the contents of the werks field by "," into:

...........

<ITAB_WERKS>

<item>

<WERKS>1200</WERKS>

<WERKS>1300</WERKS>

</item></ITAB_WERKS>

</ns1:ZAGILE_CREATE_CHANGE_MATERIAL>

Accepted Solutions (1)

Accepted Solutions (1)

justin_santhanam
Active Contributor
0 Kudos

Hi,

Use the below code.

//Advance UDF (type =queue, one input parameter)

String werks = input[0];

StringTokenizer st = new StringTokenizer(werks,",");

while(st.hasMoreTokens())

{

result.addValue(st.nextToken());

}

Werks--UDF---Werks

raj.

Edited by: Raj on Jan 31, 2008 9:06 AM

Former Member
0 Kudos

Perfect. Only thing that threw me was I had to use the same function on the ITEM and Werks level. After I did that it would split the field just like I expected. I gave full points.

Thanks

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

In your case, you can using UDF with cache type of Value, Context or Queue, they should all works.

You can also use following code:

========Using Cache By Value=====

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

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

result.addValue(b<i>);

========Using Cache By Context or Queue=====

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

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

result.addValue(b<i>);

in braket (), should be b<i>, but it does not posted this way

Liang

Edited by: Liang Ji on Jan 31, 2008 4:36 PM

Former Member
0 Kudos

Mordeb,

You can write a user defined function and split.

Regards,

---Satish