cancel
Showing results for 
Search instead for 
Did you mean: 

RFC returning empty XML

Former Member
0 Kudos

Hi all,

I am calling an RFC using a receiver channel.

The XML that i have formed in the UDF looks perfect but i am not receiving any response from the RFC. when i run the message mapping in Debug mode, an empty XML is only formed after calling the RFC.

I have checked the RFC in the SAP system and it is returning values with the same input that i am giving to the UDF.

Any help would be greatly appreciated.

regards,

Sherin Jose P

Accepted Solutions (0)

Answers (4)

Answers (4)

prasannakrishna_mynam
Contributor
0 Kudos

Hello Sherin,

Check the following cases.

- Check the Business System and Communication channels that you have configured for the RFC.

- When forming the Xml in your UDF always its better practise to import the RFC in IR and take the XML source of it as the root node of the xml should be the RFC name.

- In order to find the problem enclose your code in try catch and using MessageTrace throw the lookup exception

- Finally check that your RFC properties.

Regards,

Prasanna

Former Member
0 Kudos

Hi Sherin,

If you have wrong input values or if you are sending the format which is wrong then you get the empty xml. While sending in the input if you have a numbe field of lenght 10 and if your input is 123 try to send with leading zeros like 0000000123.

Regards,

---Satish

Former Member
0 Kudos

Hi Sathish,

Your reply was really helpful and thanks for that. I had given my number field padded with zeros now, but still it is not working. The code that i am using is:

// declare parameters

java.util.Map map;

String strReturnValue = "";

map = container.getTransformationParameters();

String busSys = "xxx"; //BuisnessSystem

int i=0;

String strRFCXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><ns0:XX_RFC xmlns:ns0=\"urn:sap-com:document:sap:rfc:functions\"><L_CUST_INPUT><item><L_CLIENT>010</L_CLIENT><L_CUST_NUM>0004100029</L_CUST_NUM><L_SALES_ORG>0151</L_SALES_ORG><L_DIST_CHANNEL>02</L_DIST_CHANNEL><L_DIVISION>02</L_DIVISION></item></L_CUST_INPUT></ns0:XX_RFC>";

AbstractTrace trace = container.getTrace();

RfcAccessor rfcaAccessor = null;

ByteArrayOutputStream baosOut = null;

try

{

// 1. Determine a communication channel (Business system + Communication channel)

Channel chChannel = LookupService.getChannel(busSys,"gSAP_MasterData_RFCLookUp_Receiver");

// 2. Get a RFC accessor for the channel.

rfcaAccessor = LookupService.getRfcAccessor(chChannel);

// 3. Create an XML input stream that represents the RFC request message.

InputStream isInputStream = new ByteArrayInputStream(strRFCXML.getBytes());

// 4. Create the XML Payload

XmlPayload xmlpPayload = LookupService.getXmlPayload(isInputStream);

// 5. Execute the lookup.

Payload pResult = null;

pResult = rfcaAccessor.call(xmlpPayload);

InputStream isIn = pResult.getContent();

// 6. Create a DOM structure from the input XML

DocumentBuilderFactory dbfFactory = DocumentBuilderFactory.newInstance();

DocumentBuilder dbBuilder = dbfFactory.newDocumentBuilder();

Document docDocument = dbBuilder.parse(isIn);

trace.addDebugMessage("Amit"+docDocument);

NodeList nlList = docDocument.getElementsByTagName("KUNNR"); // The lookupValue is available as strReturnTag in the response

Node nNode = nlList.item(0);

if (nNode != null)

{

nNode = nNode.getFirstChild();

if (nNode != null)

{

strReturnValue = nNode.getNodeValue().trim();

}

}

//if(strReturnValue.length()==0||strReturnValue.trim().equalsIgnoreCase("0"))

/*if(strReturnValue.length()==0)

throw new Exception("*** OASIS *** [" + strReturnTag + "]value returned by RFC [YRFC_YDATACONV] is [" + strReturnValue + "] which is invalid!! Please check the table [YRFC_YDATACONV] for valid entries. The input passed to this RFC were [Altsys=" + altsys + "] [Objkey=" + objkey + "]");*/

//if(strReturnValue.equalsIgnoreCase("0"))

// 7. To free resources, close the accessor..

if (rfcaAccessor!=null)

{

try

{

rfcaAccessor.close();

}

catch (LookupException e)

{

trace.addWarning("Error while closing accessor " + e.getMessage() );

}

}

}

catch (Exception e)

{

throw new RuntimeException(e.toString());

}

// 8. return a single id value to the message mapping

//return returnValue.valueOf(i);

return strReturnValue;

Regards,

Sherin Jose P

Former Member
0 Kudos

Hi Sherin,

Its very hard to identify where it is going wrong. It seems you are trying to get the response and parsing the response for a value. You can do a step by step approach for this. First dont parse any response, remove the parsing statements and first get the response directly and see whether in the response you have the values or not. If you have values then we can do the parsing.

Regards,

---Satish

Former Member
0 Kudos

Hi All,

I tried all the possibilities, still it is not returning any values.

Is there any other place where i could have gone wrong.

Regards,

Sherin Jose P

Former Member
0 Kudos

Hi Sherin,

Were you able to find the solution to your issue?

I am also facing the same issue, wherein the RFC is returning the correct values in se37 but through the RFC call, the node equals null and hence empty value is returned from the lookup.

The strangest part is that the RFC lookup was working fine till couple of months back, and had been exported from dev to quality too. Now due to a chnge, we re-tested the interface and the lookup is not functioning anymore.

Please let me know if you were able to solve this.

Thanks,

Divya

Former Member
0 Kudos

Hi Sherin,

If you have wrong input values or if you are sending the format which is wrong then you get the empty xml. While sending in the input if you have a numbe field of lenght 10 and if your input is 123 try to send with leading zeros like 0000000123.

Regards,

---Satish

former_member750652
Contributor
0 Kudos

Hi Sherin,

Can you please share the RFC lookup code so that it will be very helpful for us to make out the error?

Thanks,

Ram.