SAP RFC Function Module as REST GET service
This is my first blog.
This is a step by step example of how to consume RFC function module as REST Service using GET operation.
System: SAP PI 7.4
This example will follow this workflow:
3rd Party System <-> PI RESTAdapter (JSON) <-> PI Mapping (XML) <-> PI RFC Adapter(XML) <-> SAP R3
Bussiness Case Description
A 3rd party system consumes a REST service which published in SAP PI to get the company name and the city.
Scenario – We are going to pass Company Code(BUKRS) as a parameter (GET operation) and get the Company Name and City as output.
- Import the Function Module to ESB.
- I used external definitions as data types.
- Create Service Interface. Use External Definitions for the Request and Response.
- Create Message Mapping for Request and Response.In Request Mapping Add Custom Function.
- I have added function named getBUKRS with two parameters which named namespace and attribute.
- Added following code into the function body.(This function is usnig for extract the parameter from the URL)
Map<String, Object> all = container.getInputHeader().getAll();
DynamicConfiguration dynConf = (DynamicConfiguration)all.get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key = DynamicConfigurationKey.create(namespace, attribute);
- Map Request as following. Pass http://sap.com/xi/XI/System/REST and “id” for the constants.
- Map the response.
- Create Output Mapping.
- Go to Integration Builder and create receiver and sender communication channels.
- Create Integrated Configuration.
- Test using SOAP UI.