on 05-10-2010 2:54 AM
Hi All,
I have a requirement where in i need to check the input string length for greater than 132 and when found so it needs to be appended for every 132 characters. Please let me know the UDF to acheive the same.
Thanks in advance,
Sai
Hi Sai,
Need little more explanation from your side....
i need to check the input string length for greater than 132 and when found so it needs to be appended for every 132 characters
If input string length >132 char then append ?
If input string length <132 char. then ?
In general , PI mapping requirements are like
If particular field length is 10 and we are getting 5 fields then we append the remaining 5 places with spaces.
this is done basically when the output file is of fixed length and we need to preserve the lengths.
Please share your requirement or solution if already you got the way to implement.
Regards,
Srinivas
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi ,
Try this,
int textLen = input[0].length();
String sub;
if (textLen > 132)
{
int si = 0;
int ei = 132;
while (si < textLen)
{
if (ei > textLen) ei = textLen;
sub=input[0].substring(si,ei);
result.addValue(sub);
si = ei;
ei = ei+132;
}
}
else
{
result.addValue(input[0]);
}
This UDF must be a Queue type with one input parameter with name "input"
Regards,
Ravi
Hi,
Try with this UDF,
public String appenString(String input,Container container)
{
String output = input;
for(int i=input.length();i<132;i++)
{
output = output + " "; // i considered u want to postfix with space... if anything else change accordingly the 2nd parameter.
}
return output;
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
if str length is greater 132 what needs to be appended? i think your requirement will be if string length is less than 132 then need to append with spaces till 132.
correct me if my understanding is not correct.
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 |
---|---|
79 | |
9 | |
9 | |
7 | |
7 | |
6 | |
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.