on 04-29-2010 2:11 PM
Hi everybody,
I'd like to split a long string into smaller part fixed lenght in a mapping.
I have an XML as input like
<MT010_input>
<row>
<field>firstdefinitionttttttttttttttttttttttttttttttttt</field>
</row>
<MT010_input>
and I'd like to have at the output an XML like
<MT010_output>
<item>
<part>first</part>
</item>
<item>
<part>defin</part>
</item>
.....
</MT010_output>
Here in the example, I split the string of <field> into <part> with a length of 5 characters
ThIs is probablbly can be done in a user defined function .
Can anybody help me ?
I'm not an expert in java .
Thank you in advance for your help.
Kind regards
Hi Eric
You can use the following code in the mapping
while((field[0].length()-5)>0)
{
result.addValue(field[0].substring(0,5));
result.addContextChange();
field[0]=field[0].substring(5,field[0].length());
}
result.addValue(field[0]);
Regards
Ram
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Refer the below blog for more info on writing UDF fn.
/people/rohit.kalugade/blog/2008/12/08/context-and-queue-in-message-mapping-udf
/people/harrison.holland5/blog/2006/12/08/mapping-context-changes-in-xi
Regards
Ramg
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
1. Use the Substring in your function,
2. add the value to the resut (result.addValue)
3. Add Context Change (result.addContextchange)
Regards
Ramg
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
88 | |
10 | |
10 | |
9 | |
7 | |
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.