cancel
Showing results for 
Search instead for 
Did you mean: 

RFC is not returning parameters

Former Member
0 Kudos

Hi All,

I have written an Java code in my UDF to call the RFC. Basically i am sending some Import parameters to RFC and getting the Export parameters from the RFC. My RFC structure is like this.

XX_RFC

IMPORT

a

b

EXPORT

c

d

e

My UDF code (Queue) is :

AbstractTrace trace;

java.util.Map map;

map = container.getTransformationParameters();

trace = container.getTrace();

trace.addDebugMessage(" XX_RFC lookup started ");

String strSystem = (String) map.get(StreamTransformationConstants.RECEIVER_SERVICE);

String[] tagNames = { "a", "b"};

ArrayList arrayList = new ArrayList();

int iNoOfValuesToBeSet = a.length;

try {

RFCLookup rfcl = new RFCLookup("XX_RFC");

rfcl.setConn(strSystem,"RFCLookUp_Receiver");

arrayList.add(a);

arrayList.add(b);

rfcl.setTable(arrayList, "IMPORT", tagNames, iNoOfValuesToBeSet);

trace.addInfo(" Table set. Going to invoke RFC.");

trace.addDebugMessage("\n Start of Request XML \n" + rfcl.getRequestRoot() + "\n *** End of Request XML *** \n");

rfcl.invoke();

trace.addInfo("RFC invoked. Parsing the Response.");

trace.addInfo("\n Start of Response XML \n" + rfcl.getResponseRoot() + "\n *** End of Response XML *** \n");

strArrTempOut1 = rfcl.getParam("EXPORT", "c");

strArrTempOut2 = rfcl.getParam("EXPORT", "d");

strArrTempOut3 = rfcl.getParam("EXPORT", "e");

}catch (Exception e) {

trace.addWarning("!!! Exception caught !!! " + e+ " : \n" + e.toString());

}

finally

{

}

I have declared all the global variables in the Java section and i am writing an UDF for using those global variables.

the UDF (Queue) is :

if(strArrTempSTRASOut == null)

{

result.addValue("");

}

else

{

for (int i=0;i<strArrTempOut1.length;i++)

{

result.addValue(strArrTempOut1<i>);

}

}

When i call the RFC with a valid data, my output XML is not getting formed actually. But, the RFC is working fine when i check it in the SAP system. Any help would be greatly appreciated.

regards,

Sherin Jose P

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos
former_member750652
Contributor
0 Kudos

Hi Sherin,

Please refer the following blog to acehive your Functionaliy.Its very simple to use and .Because the lookup code gives you RFC response as XML. apply the DOm parisng code to get the desired value from the output XML structure.Follow the article and use the following piece of code in the 5th step of the code given in the article.

http://www.sdn.sap.com/irj/scn/index;jsessionid=(J2EE3417400)ID0702528050DB00626426829334031456End?r...



*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();*/  you can avoid the commented code

	  DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();

	  DocumentBuilder builder = factory.newDocumentBuilder();
	  Document document = builder.parse(in);

	  NodeList list = document.getElementsByTagName("C"); //same way for D, E
	  Node node = list.item(0);
	  if (node != null) {
		  node = node.getFirstChild();
		  if (node != null) {
			   Cvalue = node.getNodeValue(); //Desired value of C in string
		  }
	  }

Thanks,

Ram.

Former Member
0 Kudos

IS output is expected for your input from RFC ? Execute the RFC directly and check the output.

if output is expected and not returning anything it can be

1. authorisation issue

2. may be response structure is diffferent from what you are expecting

try to add the trace to see the request and response message in UDF

Rajesh