cancel
Showing results for 
Search instead for 
Did you mean: 

Urgent: RFC Lookup for BAPI in XI

shweta_walaskar2
Contributor
0 Kudos

Hi,

I am trying to call a BAPI that exists in XI system,in the Message Mapping in same XI system.

If I run the BAPI,it is working fine.

But if I call this in XI Message Mapping using RFC lookup,it returns garbage.

I am not getting any RFC error.

Can anyone please tell me what could be the reason for this.

Thanks.

Best Regards,

Shweta

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

Try to do the Lookup using the XSLT with a java helper class(if graphical mapping is not a mandatrory requirment , .........since you can avoid the java prasing and handle the same with a line of x-path.

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/05a3d62e-0a01-0010-14bc-adc...

Cheers

Sunil.

Former Member
0 Kudos

Hi Shwetha,

Please refer the below weblog:

• RFC lookup using JCO (without communication channel)

/people/sravya.talanki2/blog/2005/12/21/use-this-crazy-piece-for-any-rfc-mapping-lookups

• RFC lookup with communication channel.

/people/alessandro.guarneri/blog/2006/03/27/sap-xi-lookup-api-the-killer

Sample code:

public void createAlert(String InterfaceID, String AlertCategory, String errorString,String RFCReceiverCommunicationChannel,String BusinessService)

{

try{

final String SAPRFCNS = "urn:sap-com:document:sap:rfc:functions",

FUNCTION_MODULE= "Z_FI_RAISE_ALERT";

DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();

DocumentBuilder builder = null;

factory.setNamespaceAware(false);

factory.setValidating(false);

try {

builder = factory.newDocumentBuilder();

} catch (Exception e) {

}

Document docReq =null;

try {

docReq = builder.newDocument();

Node root = docReq.appendChild(docReq.createElementNS(SAPRFCNS, FUNCTION_MODULE));

// Creates XML structure which is passed to ABAP function module

root.appendChild(docReq.createElement("I_INTERFACE_ID")).appendChild(docReq.createTextNode(InterfaceID));

root.appendChild(docReq.createElement("I_ERROR")).appendChild(docReq.createTextNode(errorString));

root.appendChild(docReq.createElement("I_ALERTCAT")).appendChild(docReq.createTextNode(AlertCategory));

} catch (Exception e) {

}

// XML Payload

Payload result1 = null;

try {

Channel channel = LookupService.getChannel(BusinessService, RFCReceiverCommunicationChannel);

RfcAccessor accessor = LookupService.getRfcAccessor(channel);

InputStream is = new ByteArrayInputStream(docReq.toString().getBytes());

XmlPayload payload = LookupService.getXmlPayload(is);

result1 = accessor.call(payload);

} catch (LookupException e) {

// trace.addWarning("Error during lookup - " + e);

// System.out.println(e.toString());

}

}

catch(Exception e)

{

// System.out.println(e.toString());

}

}

Thnx

Chirag

Former Member
0 Kudos

Shweta, what garbage does it return?

Don't forget, you'll receive back an XML document and it needs to be parsed! Your UDF must handle the response and return only relevant value.

Peter