Graphical RFC Lookup and How you can design lookups for multiple values to be retrieved in a single call


SAP PI Interview Questions and SAP PI Tutorials

SAP PI Interview Questions and SAP PI Tutorials

Graphical RFC Lookup and How you can design lookups for multiple values to be retrieved in a single call

The Requirement:

1. Lookup for a value in ECC and populate the target with the result

2. The input data has the node (that contains the input field to the RFC lookup) with occurrence as Unbounded

3. The target node (that holds the target field) is Unbounded

The Ideal Design:

The requirement is fairly easy. You can do a simple lookup per input value and retrieve the data. But when the input field occurrence is more than say 1000, it means there is a huge overhead in terms of having to do that many lookups. (Imagine 1000 RFC calls in one single execution of the mapping)

So the RFC lookup should ideally take multiple values as its input and respond back with multiple values.

What we can do:

1. Design a RFC which will have a Table parameter.

image

Note: The structure referred has three fields (optional fields). The first two fields can be used as input and the third field is the corresponding output. In this example, only the postcode field is being filled.

2. Use the RFC in the RFC Lookup function.

The trick here is to design your mapping so as to have a single call initiated instead of multiple calls. In PI Terms, that means you will have to play around with the context. Sounds easy, but we all know playing around with contexts can be a pain and in a way fun πŸ™‚

image

For the RFC to be execute only once, we will have to create the complete RFC request structure (multiple item nodes) at one go, initiate the call, get the response and close the accessor.

So the logic for the mapping would be to replicate the ‘Item’ node of the RFC and provide the input value to each corresponding Postcode field of the Item node.

Display Queue of the RFC lookup Function:

image

What the above means is that there is one call, with 12 Item nodes each containing a Postcode as input.

On execution, with the trace level as ALL you would be able to see the RFC request being build as we expect it to be;

image

The complete Log (for the RFC request being build and receiving the response in one single call) can be seen here;

Start tag [ns0:ZFM_NGMDATA_LOOKUP]
Add raw attribute [ xmlns:ns0=”urn:sap-com:document:sap:rfc:functions”]
Start tag [NGMDATA_LOOKUP]
Add raw attribute []
Start tag [item]
Add raw attribute []
Start tag [ORDERID]
Add raw attribute []
Put value []
Close tag [ORDERID]
Start tag [POSTCODE]
Add raw attribute []
Put value [LE33 3GB]
Close tag [POSTCODE]
Start tag [INDICATOR]
Add raw attribute []
Put value []
Close tag [INDICATOR]
Close tag [item]
Start tag [item]
Add raw attribute []
Start tag [ORDERID]
Add raw attribute []
Put value []
Close tag [ORDERID]
Start tag [POSTCODE]
Add raw attribute []
Put value [TSE]
Close tag [POSTCODE]
Start tag [INDICATOR]
Add raw attribute []
Put value []
Close tag [INDICATOR]
Close tag [item]
Start tag [item]
Add raw attribute []
Start tag [ORDERID]
Add raw attribute []
Put value []
Close tag [ORDERID]
Start tag [POSTCODE]
Add raw attribute []
Put value [TSE]
Close tag [POSTCODE]
Start tag [INDICATOR]
Add raw attribute []
Put value []
Close tag [INDICATOR]
Close tag [item]
Start tag [item]
Add raw attribute []
Start tag [ORDERID]
Add raw attribute []
Put value []
Close tag [ORDERID]
Start tag [POSTCODE]
Add raw attribute []
Put value [7PF NG17]
Close tag [POSTCODE]
Start tag [INDICATOR]
Add raw attribute []
Put value []
Close tag [INDICATOR]
Close tag [item]
Start tag [item]
Add raw attribute []
Start tag [ORDERID]
Add raw attribute []
Put value []
Close tag [ORDERID]
Start tag [POSTCODE]
Add raw attribute []
Put value [6JB HU4]
Close tag [POSTCODE]
Start tag [INDICATOR]
Add raw attribute []
Put value []
Close tag [INDICATOR]
Close tag [item]
Start tag [item]
Add raw attribute []
Start tag [ORDERID]
Add raw attribute []
Put value []
Close tag [ORDERID]
Start tag [POSTCODE]
Add raw attribute []
Put value [1AA B90]
Close tag [POSTCODE]
Start tag [INDICATOR]
Add raw attribute []
Put value []
Close tag [INDICATOR]
Close tag [item]
Start tag [item]
Add raw attribute []
Start tag [ORDERID]
Add raw attribute []
Put value []
Close tag [ORDERID]
Start tag [POSTCODE]
Add raw attribute []
Put value [7SY S5]
Close tag [POSTCODE]
Start tag [INDICATOR]
Add raw attribute []
Put value []
Close tag [INDICATOR]
Close tag [item]
Start tag [item]
Add raw attribute []
Start tag [ORDERID]
Add raw attribute []
Put value []
Close tag [ORDERID]
Start tag [POSTCODE]
Add raw attribute []
Put value [0QG BD20]
Close tag [POSTCODE]
Start tag [INDICATOR]
Add raw attribute []
Put value []
Close tag [INDICATOR]
Close tag [item]
Start tag [item]
Add raw attribute []
Start tag [ORDERID]
Add raw attribute []
Put value []
Close tag [ORDERID]
Start tag [POSTCODE]
Add raw attribute []
Put value [4SU B69]
Close tag [POSTCODE]
Start tag [INDICATOR]
Add raw attribute []
Put value []
Close tag [INDICATOR]
Close tag [item]
Start tag [item]
Add raw attribute []
Start tag [ORDERID]
Add raw attribute []
Put value []
Close tag [ORDERID]
Start tag [POSTCODE]
Add raw attribute []
Put value [1YH LE33]
Close tag [POSTCODE]
Start tag [INDICATOR]
Add raw attribute []
Put value []
Close tag [INDICATOR]
Close tag [item]
Start tag [item]
Add raw attribute []
Start tag [ORDERID]
Add raw attribute []
Put value []
Close tag [ORDERID]
Start tag [POSTCODE]
Add raw attribute []
Put value [6AB HU7]
Close tag [POSTCODE]
Start tag [INDICATOR]
Add raw attribute []
Put value []
Close tag [INDICATOR]
Close tag [item]
Start tag [item]
Add raw attribute []
Start tag [ORDERID]
Add raw attribute []
Put value []
Close tag [ORDERID]
Start tag [POSTCODE]
Add raw attribute []
Put value [6HX RM12]
Close tag [POSTCODE]
Start tag [INDICATOR]
Add raw attribute []
Put value []
Close tag [INDICATOR]
Close tag [item]
Close tag [NGMDATA_LOOKUP]
Close tag [ns0:ZFM_NGMDATA_LOOKUP]
Document end
The RFC lookup returned an RFC responce
closing accessor.
accessor closed.

RFC Communication channel log:

SAP PI Interview Questions and SAP PI Tutorials

SAP PI Interview Questions and SAP PI Tutorials

I executed the mapping 5 times at different intervals. The log only shows 5 RFC calls made;

image
Conclusion:

Designing the RFC lookup to make a single call can improve performance considerably. Thus when you have a scenario which deals with multiple inputs (multiple fields i.e unbounded nodes), the RFC should be developed to have table parameters and the graphical mapping designed to make the right call.

Credits:

For the ABAP code for the RFC to work – Kathirvel Balakrishnan, a genius when it comes to code in ABAP

For the graphical mapping – I was too lazy to do that πŸ™‚ Thanks to Madhav Poosarla (one of the most dedicated colleagues I have worked with) for fitting in the pieces

SAP PI Interview Questions and SAP PI Tutorials

SAP PI Interview Questions and SAP PI Tutorials

Share this:
Share this page via Email Share this page via Stumble Upon Share this page via Digg this Share this page via Facebook Share this page via Twitter
www.pdf24.org    Send article as PDF   
This entry was posted in sap pi 7.1 tutorials and tagged , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *