cancel
Showing results for 
Search instead for 
Did you mean: 

String Counter code in SAP PI

Former Member
0 Kudos

HI All

I am working on a Scenario File to Soap, I want to count the number of string, my UDF function to count strings is:

public void StringCount(String[] SystemSubscriptionsBefore,ResultList result,Container container){

String inputString = SystemSubscriptionsBefore[0];

String searchFor = "CH_ELL";

int leng = searchFor.length();

int count = 0;

if(leng > 0)

{

int Index = inputString.indexOf(searchFor);

while(Index != -1)

{

count++;

Index = inputString.indexOf(searchFor, Index + leng );

}

}

System.out.println("Count = " + count);

}

And I have another function that I used to map the value to the target field

public void getActiion(String[] SystemSubscriptionBefore,String[] SystemSubscriptionAfter,String[] ItemActionIndicator,ResultList result,Container container){

String strEventIndicator = "";

String strBUAbcID = "";

int intSysBeforeCount = 0;

int intSysAfterCount = 0;

intSysBeforeCount = Integer.valueOf(SystemSubscriptionBefore[0].toString()).intValue();

intSysAfterCount = Integer.valueOf(SystemSubscriptionAfter[0].toString()).intValue();

if(ItemActionIndicator[0].equals("NEW"))

{

strEventIndicator = "A";

}

else if(ItemActionIndicator[0].equals("CHANGE"))

{

strEventIndicator = "C";

if(SystemSubscriptionBefore[0].equals("0") && SystemSubscriptionAfter[0].equals("1") )

{

strEventIndicator = "A";

}

if(intSysBeforeCount >= 1 && (intSysBeforeCount < intSysAfterCount))

{

strEventIndicator = "C";

}

}

//EVALUATE

if(strEventIndicator == "A")

{

result.addValue("A");

}

else if (strEventIndicator == "C")

{

result.addValue("C");

}

else

{

result.addValue("");

}

}

but now I am facing this error when testing on Massege Mapping:

Compilation of MM_MDM_MATERIAL_TO_CATALOGUE successful Runtime exception during processing target field mapping /ns0:MaintainCatalogueItem/ns0:Action. The message is: Exception:[java.lang.ArrayIndexOutOfBoundsException: 0] in class com.sap.xi.tf._MM_MDM_MATERIAL_TO_CATALOGUE_ method getActiion$[com.sap.aii.mappingtool.tf3.rt.C2CFunctionWrapper@137c593f,com.sap.aii.mappingtool.tf3.rt.C2CFunctionWrapper@48c74117, , com.sap.aii.mappingtool.flib3.Plainer@11827255, com.sap.aii.mappingtool.flib3.Plainer@b20336e, com.sap.aii.mappingtool.flib3.Plainer@6f108076, , ]

Basical my Scenario will search SystemSubscriptionAfter and SystemSubscriptionBefore, that is a string I am looking(CH_ELL) for then with the second UDF i mapp value to Action field (e.g A, B)

Any help will be appreciated

Thanks'

Yonela

:

Edited by: Yonela on Nov 12, 2010 1:54 PM

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

closed