Hello everyone,
I am using the below udf for RFC lookup in my mapping. the message is processed successfully but the problem is i am not getting the exact response what i need. Can anyone please suggest what would be the reason. Instead i am getting some xml data in output field.
//write your code here
String content = "";
MappingTrace importanttrace;
importanttrace = container.getTrace();
String m = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><ns0: function Module xmlns:ns0=\"urn:sap-com:document:sap:rfc:functions\">";
m = m + "<ZZ_XI_Sysid>" + Sysid + "</ZZ_XI_Sysid>";
m = m + "<ZZ_Product_ID>" + PROD_ID + "</ZZ_Product_ID>";
m = m + "</ns0:Function module>";
RfcAccessor accessor = null;
ByteArrayOutputStream out = null;
try
{
Channel channel = LookupService.getChannel("Busines system","Receiver channel");
accessor = LookupService.getRfcAccessor(channel);
InputStream inputStream = new ByteArrayInputStream(m.getBytes());
XmlPayload payload = LookupService.getXmlPayload(inputStream);
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 writing " + 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() );
}
}
if (accessor!=null) {
try {
accessor.close();
} catch (LookupException e) {
importanttrace.addWarning("Error while closing accessor " + e.getMessage() );
}
}
}
//returning the result u2013 RFC-XML.response
return content;
Thanks & Regards
Swetha