on 07-08-2008 4:50 AM
Hi,
I have a xml document that comes into a mapping as a result of lookup to SAP in XI. The xml structure is
<MT_I_RFC>
<HEADER>1212</HEADER>
<MESSAGE>TEST MESSAGE/DO NOT ERASE/TEST</MESSAGE>
</MT_I_RFC>
<MESSAGE> is 0:1.
In my mapping I need to take the content in <MESSAGE> and when I find / in the message, the content needs to be split into multiple resulting tags like below
structure of result is
<MT_FF>
<ROW>
<MESSAGE></MESSAGE>
</ROW>
</MT_FF>
<ROW> and <MESSAGE> is 0..unbounded.
After mapping the above input the result should be:
<MT_FF>
<ROW>
<MESSAGE>TEST MESSAGE</MESAGE>
</ROW>
<ROW>
<MESSAGE>DO NOT ERASE</MESSAGE>
</ROW>
<ROW>
<MESSAGE>TEST</MESSAGE>
<ROW>
</MT_FF>
can I please know how to achieve this? thanks for your help in advance.
Edited by: developer on Jul 8, 2008 5:50 AM
Hi,
Assuming source element MESSAGE occurrence is 0..1 and that of target elements ROW and MESSAGE is 0..unbounded, you can do something like this -
Map source element MESSAGE to target element MESSAGE using UDF split() shown below -
public void split(String[] a,ResultList result,Container container){
int i;
String [] temp = a[0].split("/");
for( i = 0; i < temp.length; i++ ) {
result.addValue(temp<i>);
result.addContextChange();
}
}
And map source element MESSAGE to target element ROW using UDF split2() shown below -
public void split2(String[] a,ResultList result,Container container){
int i;
String [] temp = a[0].split("/");
for( i = 0; i < temp.length; i++ ) {
result.addValue(temp<i>);
}
}
Edit: These are advanced UDFs. i.e. while creating the UDFs, under Cache, select the radio button next to Queue. This allows you to modify the entire message queue in the UDF.
Hope this helps.
Regards,
Riyaz
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
You can achieve this using Java Code/user defined function or Java Mapping, where you can generate the target structure as you required... So use Java Code to achieve the same
Regards, Moorthy
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Its possible with adding advanced UDF. Even you can existing Node Functions also such as SplitByValue, etc..
Please can you give me the data that you will be sending as input from Source mapping, whihc have formated to target mapping as given in your previous post, so I can try for exact solution
<MT_FF>
<ROW>
<MESSAGE>TEST MESSAGE</MESAGE>
</ROW>
<ROW>
<MESSAGE>DO NOT ERASE</MESSAGE>
</ROW>
<ROW>
<MESSAGE>TEST</MESSAGE>
<ROW>
</MT_FF>
Thanks
Swarup
Edited by: Swarup Sawant on Jul 8, 2008 7:54 AM
User | Count |
---|---|
101 | |
13 | |
13 | |
11 | |
11 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.