Skip to Content
author's profile photo Former Member
Former Member

Java syntax error : RFC Lookup

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Nov 30, 2007 at 08:50 AM

    Gordon,

    Guess you are using the code shown in Michal's article as it is. You need to parse the XML string and get the desired value you need and use return statement (if simple UDF) or resultlist.addvalue (if advanced UDF) to pass the output.

    Regards,

    Jai Shankar

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.