Skip to Content
0
Former Member
Oct 28, 2010 at 07:15 AM

Code to count number of string appearances and return a nunber of counts

30 Views

Hi All

I am trying to count the number of appearance of my the string when so my UDF code is:

public String StringCounter(String BM_CH_ESS,Container container)

{

String searchFor = "BM_CH_ESS";

String value = null;

int searchLength = searchFor.length();

int Count = 0;

int index = 0;

for( int i = 0; i < value.length(); i++ )

{

index = value.indexOf(searchFor, i);

if ( index != -1 )

{

Count++;

i += index + searchLength;

}

}

return Count;

}

When ever press F7 I get the error below:

Basical I want to return a number of counts.

Source code has syntax error: C:/usr/sap/###/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map6dc873d0e26211df88c6000c2973cb67/source/com/sap/xi/tf/_MM_MDM_MATERIAL_TO_CATALOGUE_.java:500: incompatible types found : int required: java.lang.String return Count;

Can u please give some suggestions

Thanks

Yonela