In an XI mapping, it is a common requirement to be able to perform data lookups. Earlier the lookup functionality was achieved using JDBC/JCO APIs in an advanced function to connect to DB/ SAP System respectively. If the lookup were to be performed with any other application system (synchronous) SOAP/ webservice, the APIs used will change accordingly. In such a case, the developer should have the knowledge of how to integration using the APIs specific to the system. Hence the Lookup code becomes System specific.
But with SP13, using Lookup API in XI, the Lookup functionality has changed and now its even simpler. The developer need not worry about to which application system is the lookup call being made.The Lookup APIs are generic in nature which allow u to perform a lookup independent of the system to which the call is being made. Another feature to be noted is, whenever a mapping program is executed on the Integration Server, the lookup API calls the required application system by using the central Adapter Engine.
For the given UserName and Password details, the Role of the user has to picked up from the DB. Below is the screenshot of the DB-Table that has been used in the scenario.
Fig.1 DataBase Table Structure
Sequence of Steps:
In Configuration Time, create an appropriate communication channel to the System with which the lookup is being performed. For example, if the lookup is to be performed with a Database System, then a communication channel for the DB should be created. The Advanced function (in Message Mapping) will use this channel to perform the lookups.
Fig.2 Communication Channel used for Lookup
In Design Time, Create all the required design time Objects to perform a Message Mapping. (Datatypes, MessageTypes, MessageMapping).
Fig.3 Message Mapping
Create a new advanced Function to perform a DB lookup.
Fig.4 Creation of a new advanced Function
Fig.4Advanced Function editor
The following is the logical flow of code used in Advanced function that performs DB lookup.
- Construct your Query String
- Determine the channel by specifying the Party, Service, Communication channel. Or only System, Communication channel
- Get a SystemAccessor for the channel.
- Execute your Query and get the resultset.
- Loop through the resultset and get the required value. If you want to store more than 1 value, then use container and global container variables for storing them.
- Close the System Accessor
Code snippet used to perform Loopkup
DB Lookup is performed when the mapping is executed.
Fig.4Output of Message Mapping
Mapping Lookups in help.sap.com gives a brief idea of how Lookups are performed.