cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping Question...

Former Member
0 Kudos

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?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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

Former Member
0 Kudos

Seriously... I really don't see how my requirement can be achieved by playing with the contexts...

I need to split a string into an array of strings of 132 characters or less.....

Did you read my requirment correctly?

Former Member
0 Kudos

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.

Former Member
0 Kudos

thank you that is exactly what i was looking for!!! Full marks

Former Member
0 Kudos

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

Answers (2)

Answers (2)

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

yes but the string could be any number of characters... so that wouldnt work...

I need to split the string into 132 characters or less