Technical Articles
Using BADI “/IWFND/BD_MGW_DEST_FINDER” to call ODATA Service of remote SAP system
Introduction
BADI /IWFND/BD_MGW_DEST_FINDER is a multi use filter dependent BADI which will take SERVICE_NAMESPACE and SERVICE_ID as filter values and has one interface method name GET_SYSTEM_ALIASES. From this BADI we can change or manipulate system alias of an odata service.
This BADI will get hit on each UI action or we can say on each backend call from UI. So suppose we have a scenario like two tabs of one UI model, for each tab we can hit different services.
Details of BADI /IWFND/BD_MGW_DEST_FINDER :
Below screen shots shows the BADI interface method and filter values
Now to use the BADI we have to create one implementation of the BADI with filter values. For filter values we can give service name space or service name itself.
How to use BADIĀ /IWFND/BD_MGW_DEST_FINDER to change system alias for a service at runtime.
Step 1: Create one Odata service in original system with 2 entities – Entity_Local and Entity_RFC. One entity will fetch data from local system. And one entity will fetch the data from RFC system.
Step 2 : Create one Odata service in the RFC system with the same name created in above step. Note : Name should be same of Odata service, entities and properties of entities in both system. Meta data will get loaded from original system hence the naming should be same.
Step 3: Register the original system service for two system aliases. One alias for the local system and one alias for RFC destination system. Keep one system as default system. This configuration will looks like below.
How to create system alias for a RFC destination is given in below link
https://blogs.sap.com/2014/11/04/steps-to-access-the-gateway-service-from-one-system-to-another-system/.
Step 4: Now click on SAP Gateway Client.
Put a debugging in implementation of BADI in the original system. Select the entity for which you want to fetch the data. Click on GET. Debugging will start. The BADI interface method has one changing parameter which will have both the registered system alias at run-time
BADI also has one parameter IT_REQUEST_ATTRIBUTES which will contain entity name.
You can manipulate the system alias using below pseudo code.
LOOP IT_REQUEST_ATTRIBUTES
INTO LV_STRING.
ENDLOOP.
IF LV_STRING CS ‘ENTITY_LOCAL’
SYSTEM_ALIAS = LOCAL.
ELSEIF LV_STRING CS ‘ENTITY_RFC’.
SYSTEM_ALIAS = RFC.
ENDIF.
Hence like this you can hit two different system for two different entities.
Woderful article very helpful
Good Blog.