on 05-08-2014 10:15 AM
Hi,
I have a requirement where TDLINE will carry some characters which is not fixed.It can be 70 ot 280.
My Requiremnt:-I want to split the string into 70 characters only.So,if we are getting 280 character in string ,I want to divide it into 4 line(70 each )
Suppose,if we have 150 character than we will divide it into 70,70 and 10 character.
Please suggest your view.
i used this UDF in one project exactly similar situation but the length was 255 anyways i added a variable you can decide the length yourself
i used this as input
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
code is
//start
int i=0;
int len = Integer.parseInt(field_length[0]);
String str= Customer_notes[0];
double line= Math.ceil(Customer_notes[0].length() / (float)len );
int lines = (int)line;
int traversed = 0;
for(i=0; i <lines; i++)
{
String current_str = "";
if( str.length() >= len && len > 0)
{
current_str = str.substring(0,len);
TDLINE.addValue( current_str );
}
else
{
current_str = str;
TDLINE.addValue(current_str);
}
traversed = traversed + current_str.length();
str = Customer_notes[0].substring(traversed, Customer_notes[0].length());
}
//end
it never gave me a problem .
Cheers
Vinay
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ravi,
please check this thread http://scn.sap.com/message/14883112#14883112
you can add third and fourth items as in my example or use UDF
Regards, Mikhail
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
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.