It is not a new one. It is a old hack with a new dress. Can we do RFC mapping lookups with a single crazy piece? Yes. You can. Did you know about RFC_READ_TABLE? It is not a new one but I added XI flavour to RFC_READ_TABLE by re-dressing it as a re-usable lookup API.
SAP XI being existent more often in a typical SAP landscape we need to deal more with SAP systems in real-time. It is obvious for any XI developers that this lookups are very common in any XI projects. We used to write user defined functions and JCO wrapper classes and create custom RFCs for lookups. Why do it every time on every project? Can we perform RFC lookups using the same standard RFC template provided by SAP?
I am going to demonstrate this exercise using a JCO instead of mapping lookup APIs since we are working still on SP12.I cant really wait until the server is upgraded to the next patch for elucidating the idea. May be am afraid someone else might come up before me. Idea can be extended to the RFC mapping lookup APIs also!
Let me describe the behaviour of RFC_READ_TABLE.
Functionality: It consumes the table name and filters that are used to fetch data from any SAP ABAP DD tables and produces the result set dynamically.
QUERY_TABLE-ABAP Table Name
OPTIONS-filters (WHERE CLAUSES)
FIELDS-ABAP Table Structure
DATA-ABAP Table Data
Instance: I want to fetch all the error IDs for the mapping category using the table SXMSSYERR (XI: System Error Codes). Let us test the RFC in the SE37 transaction code of SAP XI. Table Structure: SXMSSYERR
OPTIONS-CATEGORY = Mapping
Output:FIELDS- SXMSSYERR structure
DATA- Value table with CATEGORY and ID (error Ids).
Look at the crazy piece below. Tailor it and use it in any XI project for mapping lookups by just changing the connection parameters. It has to be enhanced for accepting the connection parameters at the runtime when you want to use the sample JCO code for performing RFC lookups across SAP systems.
I am going to show a sample mapping in XI for demonstrating the behaviour. I used a advanced user define function genRFCLookup which takes 4 parameters table name, match field, match value, lookup field. JCO code is wrapped under genRFCLookup.
I demonstrated the mapping behaviour for the same instance that is used for testing the RFC in SE37.
Target Structure: (After JCO Call)
Note: This is just a very simple lookup example. XI developers can customise the interface in such a way that can be a single point template and user-friendly for any RFC lookups across various interfaces. It can also be extended to support RFC mapping lookup APIs supported by SP13.