Skip to Content
In all xi project I worked on, lookup operations in message mapping were always an important issue with the risk to become a bottleneck. A possible solution is to use the library I developed to manage mapping lookups. The library provide a common point of access to any remote lookup function module, and provide a cache mechanism to store each result and avoid to repeat identical lookups within the same message mapping.

Prerequisite

– The system providing data lookup is a SAP system or it is able to expose a function module.
– Function modules to be called are remote enabled.
– The type of importing and exporting parameters of the function modules is char.

How the library works

image
1 – Internal logical flow of the Lookup Library

How to use the library in your Message Mapping

Step 1: In the Integration Directory create an RFC Receiver Communicational Channel to the System that contains lookup function modules.

Step 2: Import DataLookupOptimized.jar into Integration Repository (SWCV -> Your Namespace -> Mapping Objects -> Imported Archive)

Step 3: In the graphical mapping editor create a simple function and import the package it.techedge.sap.xi.utils.datalookup

Step 4: Retrieve the data look up provider object from the globalContainer

Step 5: Create the list of parameters to be provided to the RFC:

Step 6: Execute the data look up by calling the method provideDataLookUp with the following parameters:
– String systemName: name of the system that exposes the RFC;
– String remoteFunctionName: name of the remote function that resolve data look up;
– String outputFieldName: name of the output field to be retrieved (the RFC can return more than one output value);
– ArrayList rfcParams: array of params to be provided to the RFC. Note that the order of parameters in the array must respect the order defined in the RFC. If a parameter is not provided the value null must be added to the array.
The method returns a String corresponding to the RFC exporting parameter named outputFieldName.

Step 7: Store the dataLookUpProvider object in the global container

Example

In this example a data look up is performed to retrieve the FLIGHT_DESCRIPTION_SHORT associated to the field FLIGHT_CODE of the outbound message interface.

RFC details:
– Name: “Z_FLIGHT_CODE_TO_DESCRIPTION”
– Importing parameters
     – FLIGHT_CODE
     – LANGUAGE
– Exporting

     – FLIGHT_DESCRIPTION_LONG
     – FLIGHT_DESCRIPTION_SHORT

Mapping:
image
2- Mapping Overview using Lookup UDF

User defined function:
– Name: “transcodeCodeToFlightDescription”
– Parameters:
     – SystemName(String): BS_EP1CL010
     – remoteFunctionName(String): Z_FLIGHT_CODE_TO_DESCRIPTION
     – outputFieldName(String): FLIGHT_DESCRIPTION_SHORT
     – flightCode(String): flight code from outbound interface
     – languageCode(String): language code from outbound interface
     – container(container, automatically added)
-Imports: it.techedge.sap.xi.utils.datalookup

image
3 – Lookup User Defined Function Code

Lookup User Defined Function Code Snippet

Reference

You can download my library here.

The library is based on SAP Lookup Library API:
https://help.sap.com/javadocs/NW04S/SPS09/pi/index.html

Special thanks to my colleagues Sandro Garofano and Sergio Cipolla, with their suggestions they really helped me.

To report this post you need to login first.

6 Comments

You must be Logged on to comment or reply to a post.

  1. Former Member
    Hi

       It’s good weblog. You have written ‘… cache mechanism to store each result and avoid to repeat identical lookups within the same message mapping’. I have few doubts in this.
    1. Will Global Container works across message mapping?
    2. How about the persistence of messages in cache
    if Global Container Supports across mappings?
    3. If I use JDBC lookup instead of RFC, What will be change in logic which you use for RFC ?

    Kindly Reply,
    Jegatheeswaran P.

    (0) 
    1. Former Member Post author
      Hi Jegathees,
      The scope of GlobalContainer is just the instance of a Message Mapping, then the persistence of the values in the cache is within the execution of the mapping program.
      Here the reference:
      http://help.sap.com/saphelp_nw04s/helpdata/en/75/8e0f8f3b0c2e4ea5f8d8f9faa9461a/content.htm

      I developed this library just for RFC lookups, and if you want to add also the support for jdbc lookup you have to do a lot of changes.
      These changes will affect the way to perform the lookup (DataBaseAccessor instead of RFCAccessor) in the class RFCHandler, and you have to implement the dynamic construction of the sql statement based on the structure of the table.

      Best Regards,
      Francesco

      (0) 
  2. Former Member
    Ah, Techedge Guys… Too bad.
    Have you ever – by mistake – pointed your browser here?
    The specified item was not found.
    It’s all said, but it’s more generic,
    it supports JDBC lookup as well.
    All in one.

    The only good thing I can see here is cache handling (via GlobalContainer) inside the lib, and not in the UDF.

    “Meditate people, meditate”
    (R. Arbore, in that good old italian beer tv ad)

    (0) 
  3. Former Member
    Hi Francesco

    I tried using your lookup with input param as MESTYP and MESCOD, MESCOD has an empty value, so instead of passing a null (i do not want to pass a null), I try to pass an empty string. But weirdly the value gets replaced by a hash before it gets sent to the function module. I checked this out by activating the RFC trace in ST05. Do you know why this is happening??

    regards
    Sameer

    (0) 
  4. Former Member
    Hi Francesco,

    very good job, clear and useful. I’ve tried it on a customer and all it’s gone well with only a bit of work on my side. ๐Ÿ™‚

    (0) 
  5. Former Member
    Hello Francesco,
    i Try your Scenario and it works very well.
    Only the name of the Channel as GeneratedReceiverChannel_RFC seems to bee hard coded in your library??
    Is there any change to make also the Name of the Channel dynamic like the Name of the service ??
    Regards
    Ralf Zimmerningkat
    (0) 

Leave a Reply