cancel
Showing results for 
Search instead for 
Did you mean: 

Is is possibel to do an RFC Lookup from The Graphical Mapping?

Former Member
0 Kudos

Greetings,

While doing a message mapping I need to get the value from R3 system using an RFC, is it is possible ?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi

we can do by using rfc look ups

Lookup in mapping is the feature provided by SAP to lookup the data in the target R/3 or DB systems with the API provided.

You need to write UDF in order to implement the API's provided by SAP.Consider the below example

VendorNumber-UDF--CURR

The scenario is legacy to SAP. The legacy system doesn't provide the currency details. But the target field need's to be populated with currency value.

"The business rules says there are values maintained in SAP Table where if you pass VendorNumber it will return thr currency to you"

So what you can do? You can write UDF implementing SAP Provided API's and do a lookup in the SAP System and get back the currency value and populate them in CURR field.

I hope it clears a bit.

Please find the below blogs

DB Lookup: /people/siva.maranani/blog/2005/08/23/lookup146s-in-xi-made-simpler

RFC Lookup:https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/a03e7b02-eea4-2910-089f-8214c6d1b439

There are three types of look ups u can do

RFC look up

SOAP look up

JDBC look up

What is Lookup and why we need:

Within an XI mapping it is a common requirement to be able to perform data lookups on-the-fly. In particular, there may be a need to look up some data that is maintained in an R/3 application.

In the error handling topic we have seen the different validations which need to be performed on file. This can be done through Lookup.

Some use cases:

• Look up material number from table MARA.

• Look up cost center budget.

• Look up employee information.

• Look up unit-of-measure (UOM) information from table t006a.

• Lookup for raising an alert.

The purpose of the lookup may be:

• To perform application-level validation of the data, before sending it to the backend.

• To populate fields of the XML document with some additional data found in the backend application.

This is a form of value transformation.

The "value mappings" offered by XI are not adequate in this case, since the data would have to be manually entered in the Integration Directory.

There are two ways in which we can do lookup:

• Call lookup method from GUI mapping.

• Call lookup method from XSLT mapping.

Lookup method from GUI mapping can be called using any of the following ways.

• 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

• Lookup using JDBC adapter.

/people/siva.maranani/blog/2005/08/23/lookup146s-in-xi-made-simpler

/people/sap.user72/blog/2005/12/06/optimizing-lookups-in-xi

• CSV file lookup.

/people/sundararamaprasad.subbaraman/blog/2005/12/09/making-csv-file-lookup-possible-in-sap-xi

Lookups with XSLT - https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/8e7daa90-0201-0010-9499-cd347ffb...

/people/sravya.talanki2/blog

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

DB lookup - /people/siva.maranani/blog/2005/08/23/lookup146s-in-xi-made-simpler

SOAP Lookup - /people/bhavesh.kantilal/blog/2006/11/20/webservice-calls-from-a-user-defined-function

You can refer to these links.

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

/people/siva.maranani/blog/2005/08/23/lookup146s-in-xi-made-simpler

For Java APIs and also here you can map that how many types of lookups are possible in XI.

http://help.sap.com/javadocs/NW04/current/pi/com/sap/aii/mapping/lookup/package-summary.html

Answers (2)

Answers (2)

Former Member
0 Kudos

krishnachitanya.

this what I was looking for,

thank you very much

Gabriel Sagaya your UDF looks very clear, I will try it also

GabrielSagaya
Active Contributor
0 Kudos

Yes

purchaseorder>myRFC->purchaseOrder

You can do it in UDF

imports java.io.;com.sap.aii.mapping.lookup.;

function myRFC(String a,Container container)

{

String content = "";

MappingTrace importanttrace = container.getTrace();

String m = "<?xml version="1.0" encoding="UTF-8"?><p2:BAPI_PO_GETDETAIL xmlns:p2="urn:sap-com:document:sap:rfc:functions"><PURCHASEORDER>4500014790</PURCHASEORDER></p2:BAPI_PO_GETDETAIL>";

RfcAccessor accessor = null;

ByteArrayOutputStream out = null;

try

{

Channel channel = LookupService.getChannel("BCS_800","rfc_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(Exception e)

{

importanttrace.addWarning("Error while lookup " + e.getMessage() );

}

return content;

}

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/a03e7b02-eea4-2910-089f-8214c6d1...