cancel
Showing results for 
Search instead for 
Did you mean: 

UDF Problem

Former Member
0 Kudos

I am implementing a SOAP Lookup from a UDF and I keep receiving the following error:

java.lang.StringIndexOutOfBoundsException

The strange thing here is that I have developed the exact same scenario in a Sandbox system and everything works perfectly.

I have even gone to the extent of Redeveloping the scenario in our DEV system so that every object is exactly the same as that of the Sandbox but still DEV is giving me an issue.

The Code is Identicle in each system so I really cant see where I am going wrong.

Useful information may be that the sandbox is on SP 09 and dev is on SP14.

So Dev is on a higher release but is having issues that doesn't speak sense to me....

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Yes the values are identicle in both systems...

I know why the error arises my problem is why it is happening in this case as I can't see the problem with the code...

My only hunch is that Maybe the SystemAccessor class in faulty on the Dev system??!?! I can't see any other way...

Do you guys kno where I can go and look at source code directly?

Former Member
0 Kudos

The SystemAccessor is standard java library. It can't really be "wrong" in any case.

You are passing in the channel object as well. You might want to double check that the channel is set correctly.

Former Member
0 Kudos

Believe me I have checked and Rechecked the channel :-).

I know it can't be wrong but... I have to at least eliminate the possibility

Former Member
0 Kudos

Hi Alex,

This is the bug introduced in one of the recent patches of SP14 (7.0) and SP22(3.0) .

This is being fixed now hope soon it will be released soon.

thanks

amit

reward point if suggestion helps

Answers (7)

Answers (7)

Former Member
0 Kudos

HI thank you that is a lot of help.

Could you maybe point me in the direction of where you found that information please?

Full points will be awarded!!

Former Member
0 Kudos

Hi Alex,

Basically the exception arises When you are trying to read data more than the actual data available. Example :- Data available in a file is from 0-10. In your java program you are trying to read data from 0-11. where 11 bit of data is not available in your file.

The code that you have sent looks ok please check the data you are passing

Thanks

Arijit

Former Member
0 Kudos

Alex,

Are you using the same input data for testing on both the systems? If not, try using the DEV input data on sandbox and check if any errors occur.

Regards,

Riyaz

Former Member
0 Kudos

I have an update...

I have mapped a value after everyline to see where I could be getting the issue and it seems that my issue is the SystemAccessor:

conversionRate = "2";
	SystemAccessor accessor = LookupService.getSystemAccessor(channel);
conversionRate = "3";

As you could see I was returning a different value after each step to see where things were falling down and my return value is 2...

I did the hardcoding and still the same error

Edited by: Alex on Jul 11, 2008 11:51 AM

Former Member
0 Kudos

Hi Alex

Check this

Regards

Abhishek Mahajan

Former Member
0 Kudos

Hey Sorry here it is:

javax.xml.transform.stream.StreamResult;com.sap.aii.mapping.lookup.*;javax.xml.transform.dom.DOMSource;javax.xml.parsers.*;javax.xml.transform.*;org.xml.sax.*;org.w3c.dom.*;

AbstractTrace trace = container.getTrace();
String conversionRate = "";
try {
	/*Pass the Business System and Communication Channel as  input to the getChannel().
	/*BS_SOAPLOOKUP u2013 Business System*CC_Webservice_SOAP_CURRENCY_CONVERTOR u2013 Receiver SOAP Adapter */ 
	Channel channel =
		LookupService.getChannel(
			"SRV_SOAPUDF",
			"CCR_SOAP_SOAPUDF");
	SystemAccessor accessor = LookupService.getSystemAccessor(channel);
	/* Construct the SOAP Request Message using the InputParameters
	FromCurrency , ToCurrency are the Input Parameters.*/
	String SOAPxml =
		"<ConversionRate xmlns=\"http://www.webserviceX.NET/\"> <FromCurrency>"
			+ FromCurrency
			+ "</FromCurrency><ToCurrency>"
			+ ToCurrency
			+ "</ToCurrency></ConversionRate>";
	InputStream inputStream = new ByteArrayInputStream(SOAPxml.getBytes());
	XmlPayload payload = LookupService.getXmlPayload(inputStream);
	Payload SOAPOutPayload = null;
	/*The SOAP call is made here and the response obtained is in the SOAPOutPayload.*/
	SOAPOutPayload = accessor.call(payload);
	/* Parse the SOAPPayload to get the SOAP Response back. 
	 The conversion rate is available under the Field Name ConversionRateResult */
	InputStream inp = SOAPOutPayload.getContent();
	DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
	/* Create DOM structure from input XML */
	DocumentBuilder builder = factory.newDocumentBuilder();
	Document document = builder.parse(inp);
	/* ConversionRate is available in the TAG ConversionRateResult in the Response XML */
	NodeList list = document.getElementsByTagName("ConversionRateResult");
	Node node = list.item(0);
	if (node != null) {
		node = node.getFirstChild();
		if (node != null) {
			conversionRate = node.getNodeValue();
		}
	}
} catch (Exception e) {
	trace.addWarning("Error" + e);

}
return conversionRate;

Former Member
0 Kudos

Hi there,

You might want to check whether the FromCurrency and ToCurrency are correctly pass into the udf?

For a test, u might hardcode FromCurrency = "USD"; and ToCurrency = "INR"; in the udf.

you can do trace.addInfo("..."); to see where is it failing

Edited by: SAP noob on Jul 11, 2008 11:51 AM

Former Member
0 Kudos

You might want to post your codes here for us to take a look?