on 07-13-2007 4:40 PM
i have a doubt.
for example if my source data has a string of 20 characters length like
<b>
AMERICIANSTANDARDBANK
</b>
So while i transfer the source data to destination i have 2 criteria
- after the 10th character that is the 11th letter should be replaced by letter 'O' and
- the target string should contain only 15 characters, and all the characters after the 15th letter that is from 16th letter on wards should be truncated.
so target should be : AMERICIANS<u>O</u>ANDA
Satish,
Write UDF //In my udf input parameter is 'a' change accordingly.
String ret="";
if(a.length() >15)
{
ret=a.substring(0,10) "O"a.substring(11,15);
}
else if(a.length() <=10)
{
ret =a;
}
else if(a.length ()==11)
{
ret =a.substring(0,10) +"O";
}
else
{
ret =a.substring(0,10) "O"a.substring(11,a.length());
}
return ""ret"";
Best regards,
raj.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Satish,
If you always have a string of 20 characters from the input then you take a substring from 1 to 10 and then concat with 'o' and then use the UDF to get the value from 11th position to the end and then once again take the substring.
Use this UDF which gets the value from position 11 to the end:
Create a Value UDF with two input parameters. First parameter a is used to pass the length and the second parameter b is used to send the actual value to the UDF. Now add this code:
int i = Integer.parseInt(a);
String c = b.substring(11,i);
return c;
In mapping you map this two fields to the UDF:
Source>Length>UDF
Source-->UDF
It gets you the value from the 11th position to the end.
Regards,
---Satish
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.