on 07-14-2010 11:45 AM
Hello All,
I need help to write UDF
My requirement is to add trailing spaces the string depnding on the specific String startswith
For example:
Starting charcters Length
HD 55
SH 233
CR 25
So i need to check if the string is starting with specifc Key then chaeck the length and then add spaces.
Can someone please help
Thanks
Hello All,
I have written the below code:
Can someone please help how i can store length for each String and send as output
{
//write your code here
int length = 0;
String val1 = "";
for (int i=0;i<a.length;i++)
{
if(a<i>.startsWith("HD")){
length = a<i>.length();
if (length <= 33)
{
int val = 33 - length;
val1 = Integer.toString(val);
}
}
if(a<i>.startsWith("MA")){
length = a<i>.length();
if (length <= 208)
{
int val = 208 - length;
val1 = Integer.toString(val);
}
}
if(a<i>.startsWith("SH")){
length = a<i>.length();
if (length <= 47)
{
int val = 47 - length;
val1 = Integer.toString(val);
}
}
}
result.addValue(val1);
}
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
You would like to receive as result HD and length f.ex. 25 in one field in this case HD 25 ??
if yes
than check your length and use java string function concat val + length and assign it to result.
If no
and you would like to count it and once append it to target filed. UDF and and change context od source parameter of this function. Then loop on context elements and make neccesary operation. after loop append to target filed final length.
Regards
Maciej
User | Count |
---|---|
88 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.