on 02-27-2007 10:47 AM
Hi,
Have a source field whose length can be of 40 char,the target field should be 30 chars long, If shorter than 30 it should be padded with trailiing spaces to 30 chars.
Can anybody please give me UDF please points guaranteed, Please help needed.Thank you.
HI,
Use the following UDF with input first string source field,30( a number how much length the target should contain.
<b>Inputs : String a,String b</b>
while (a.length() < Integer.parseInt(b.trim())){
a = a + " ";
}
return a;
}
Regards
Chilla..
<i>points rewarded if it is usefull..</i>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
input A we are passing string A as Input to UDF.
int i=0;
i=a.length();
if (a.length() >= 40)
return a;
else
{
int j= 40 - i;
for (int k=0; k<=j; j++)
{a=a+" ";}
return a;
}
Regards
Sreeram.G.Reddy
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
try this !!!
int len = 30;
StringBuffer sBuf= new StringBuffer(a);
int originalLen = sBuf.length() ;
while (origiinalLen < len) {
sBuf.insert(originalLen,'0');
}
String resultstring = sBuf.toString();
return resultstring;
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi John,
do below: create a simple UDF - It should have String return type. Take a as input String.
if (a.length()>30)
return a.substring(0,30);
else
{
String b;
b=a;
int z = b.length();
for (int i=0;i<(30-z);i++)
b=b+' ';
return b;
}
Thanks,
Rajeev Gupta
Message was edited by:
RAJEEV GUPTA
Message was edited by:
RAJEEV GUPTA
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
95 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
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.