Skip to Content
0
Former Member
Nov 30, 2007 at 08:16 AM

Java syntax error : RFC Lookup

36 Views

My UDF Source code has an syntax error: missing return statement }

but i can´t find the error.

any ideas ?

 //write your code here
String content = "";
MappingTrace importanttrace;
importanttrace = container.getTrace();

// filling the string with our RFC-XML (with values)
String m ="<?xml version="1.0" encoding="UTF-8"?><ns0:Z_GET_PRODH xmlns:ns0="urn:sap-com:document:sap:rfc:functions"><IN_MATNR>2100018693</IN_MATNR></ns0:Z_GET_PRODH>";

RfcAccessor accessor = null;
ByteArrayOutputStream out = null;

try
{

	// 1. Determine a channel (Business system, Communication channel) 
	Channel channel = LookupService.getChannel("xxxxxxxxxx","yyyyyyyy"); 

	// 2. Get a RFC accessor for a channel. 
	accessor = LookupService.getRfcAccessor(channel); 

	// 3. Create a xml input stream representing the function module request message
	InputStream inputStream = new ByteArrayInputStream(m.getBytes());

	// 4. Create xml payload
	XmlPayload payload = LookupService.getXmlPayload(inputStream);

	// 5. Execute lookup.
	Payload result = accessor.call(payload);
	InputStream in = result.getContent();
	out = new ByteArrayOutputStream(1024);
	byte[] buffer = new byte[1024]; 

	for (int read = in.read(buffer); read > 0; read = in.read(buffer))
	{
		out.write(buffer, 0, read);
	}
	content = out.toString();

}

catch(LookupException e)
{ 
	importanttrace.addWarning("Error while lookup " + e.getMessage() );
}

catch(IOException e)
{
	importanttrace.addWarning("Error " + e.getMessage() );
}

finally
{
	if (out!=null)
	{
		 try
		{
		out.close();
		}
		
		 catch (IOException e)
		 {
			importanttrace.addWarning("Error while closing stream " + e.getMessage() );
		 }
	}


	// 7. close the accessor in order to free resources.
	if (accessor!=null)
	{
		 try
		{
		accessor.close();
		}
		
		 catch (LookupException e)
		{
			importanttrace.addWarning("Error while closing accessor " + e.getMessage() );
}
}
}

Message was edited by:

Gordon Breuer