on 04-02-2008 8:56 AM
Hi Guys,
I need a udf to split a string into an array.
Basically I could get a string with a seemingly unlimted length.
I want to then split this string into an array of 132 maximum obviously it can be less than 132 if there are not enough characters but the general gist is to split the string.
So lets say you had a string with length of 296 characters. It would then return an array with
132 characters
132 characters
32 characters
could someone provide me a udf for this please?
Hi,
Actually u need some stuff regarding the mapping functions which are present in the message mapping..
In node functions we get Split by value, Remove contexts, collapseContexts..
Split By value again has 3 possiblities -- Each Value, Value Changed, Empty Value.
and follow this documents for the information..
Remove context -
http://help.sap.com/saphelp_nw04/helpdata/en/1f/ea0fb12403844bbb6c4cbc8a00cda9/content.htm
Collapse context -
http://help.sap.com/saphelp_nw04/helpdata/en/4b/d11e3e1c3b120ae10000000a114084/content.htm
Node Functions
http://help.sap.com/saphelp_nw04s/helpdata/en/2c/2d8c4024d26e1de10000000a1550b0/frameset.htm
reddy gundala
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi... I had a similar requirement. I have used the below UDF:
String temp = "";
int j=a[0].length()/132;
int l=j;
int k=a[0].length()%132;
if(j>0){
for (int i=0;i<a[0].length()-131;i=i+ 132){
temp = a[0].substring(i,i+ 132);
result.addValue(temp);
j--;
}
}
if (k!=0){
if(j==0){
if(l==0){
temp=a[0];
}
else{
int r=l*132;
temp=a[0].substring(r,a[0].length());
}
result.addValue(temp);
}
}
This UDF will give u the desired o/p.
Hi,
here is your udf:
public void splitString(String a,Container container)
{
for(int i=0;a.length()/132-(132-a.length()%132)/5;i++)
result.addValue(a.subString(i132,i132+132)
result.addValue(a.subString(i*132,a.length());
}
**Reward points if helpful.
--Sankar Choudhury
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
U can use substring std function provided in XI. Give the start and end postiond of string and accordingly it will split the string.
Chirag
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
91 | |
10 | |
10 | |
9 | |
9 | |
7 | |
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.