OData Basics – Part 5 (Build Service with BAPI)
Let’s see how to build OData service by consuming Remote function module. Follow below steps:
Click ‘Create’ button
Enter Project, description and package as shown below:
Import data model from Remote enabled function module:
I have used BAPI_FLIGHT_GETLIST
Choose FLIGHT_LIST from parameters..
Make AIRLINEID as key field..
Define query operation and map it to data source:
Click ‘Propose Mapping’ to perform automatic mapping. As our entity set is defined based on parameters of same RFC, automatic mapping is performed. If not, we have to manually drag and drop fields to map them.
Now, click ‘Generate’ button to generate run time artifacts.
Activate service using trasanction “/IWFND/MAINT_SERVICE”
Click ‘Add Service’
Click ‘Call Browser’ to test the service:
http://<<FQDN>>/sap/opu/odata/sap/ZRZ_SERVICE_BY_RFC_SRV/$metadata will show the metadata information of our service
http://<<FQDN>>/sap/opu/odata/sap/ZRZ_SERVICE_BY_RFC_SRV/FlightListSet will return us complete data
I went back to modify the data model and included MAX_ROWS field as import parameter:
http://<<FQDN>>/sap/opu/odata/sap/ZRZ_SERVICE_BY_RFC_SRV/FlightListSet?$filter=Airline eq ‘AA’ and MaxRows eq 2
Output of RFC gave only two records now as shown in below screenshot: