Introduction: workingwith OData services on the SAP NetWeaver platform seems to be getting streamlined and simple. This is from an end-to-end perspective of developing an OData service in a SAP Backend system (with SAP Gateway component installed) as well exposing this OData service in SAP Process Orchestration. The advantages of this are enormous because, this already eliminates the use of SAP Gateway hub for exposing Gateway services. The existing SAP Backend system and SAP Process Orchestration can be leveraged, reducing the complexity of the landscape, while also reducing the total cost of ownership. Previously, developing OData services within the SAP Gateway platform seemed to be also a complex process. But also with the availability of the Gateway service builder tool (T-code: SEGW), a lot of the steps can also be easily automated. In this blog, I will try to achieve the following;
- Develop an OData service in SAP Backend (with Gateway component installed)
- Expose the developed OData service via the OData Provisioning Administration console in SAP PO.
- v SAP Backend system (with SAP Gateway component installed: IW_BEP 200 )
- v SAP NetWeaver 7.3 EHP 1 SP 13/ SAP NetWeaver 7.4 SP 08
- Following Authorization to user: GW_ADMIN and GW_USER
A) Developing OData Service in SAP Backend
Developing an OData service in SAP Backend requires that the gateway component mentioned earlier is installed on the backend system. The Service Builder Tool is used to kick-start the process of building the OData service and essentials steps required are mentioned explicitly.
Create OData Service: The following actions will be performed to develop this service;
- Run the T-code: SEGW to access the service builder tool
2. Create a project and name it appropriately as “ZODATA_SERVICE” and save as local object,
After this, the following components are created within the project;
- Data Model
- Service Implementation
- Runtime Artifacts
- Service Maintenance
3.The Data Model for the OData service can be obtained/created in several ways; there is a possibility to create Entity types and entity set from scratch, but better still Data model can be imported in three ways taking advantage of existing data structures; DDIC, File (.edmx extension), RFC/BOR. Here, a DDIC will be imported. Click on the edit mode, right click on the Data Model component and select the option “Import DDIC”
Note: you could search the DDIC structure to be imported based on; View, ABAP structure or Database Table.
4. Select any existing ABAP Structure “/1BEA/FBCB_BDI”, provide object name “Z_BillingDetails”, Mark Client field property as Key and click ‘Continue’, It creates an Entity Type;
5. Create ‘Entity Set’ as below, with the name “BillingDetailsRequest” and select the Entity Type previously created;
6. Open the ‘Entity Sets’ object and select the following properties Creatable, Updatable and Deletable;
7. After the previous step, the following methods created for the “Service Implementation”
8. Now generate the “Runtime Artifacts” by clicking on the button shown below; this automatically generates the artifacts for the OData service with predefined classes which can be modified, but we keep it as default. The newly created classes are added as local objects.
Click continue and select the “Local Object” option in the next screen
9. The generated definition for the OData service is contained in this class: ZCL_ZODATA_SERVICE_MPC, however, to implement the desired logic, the ZCL_ZODATA_SERVICE_MPC_EXT class will be extended with the additional code. Right click on ZCL_ZODATA_SERVICE_MPC_EXT, choose the option below;
10. Switch to edit mode, select the “DEFINE” option and click on the Redefine button; add the following code below; then save and activate the class.
Register OData Service in the Gateway system: After the OData service has been created based on the previous steps described, the OData service needs to be registered in the Gateway system. To do this, perform the following actions
1. Run the T-Code in the backend system: /IWFND/MAINT_SERVICE to navigate to the service maintenance screen.
2. Choose the add service option to add the service created earlier in the backend system. Providing the following information shown in the screen and ‘Enter’
3. Select the Technical Service Name and click on the local object as package, the package is filled with $TMP which is a local package;
After successful registration of the service, the following message should be displayed;
4. The OData service has been registered and it can be viewed as one of the services in the service maintenance screen.
Test the OData Service: A quick test can be confirmed on the newly created OData service can be done by;
- Select ‘ZODATA_SERVICE_SRV’ and click ‘Call Browser’. This will open Service definition in browser.
2. The Details of this newly created OData service is shown below;
B. Exposing OData Service in SAP Process Orchestration
In the previous section, a step by step guide was provided on how to create an OData service within the SAP Backend system with installed gateway component. This newly Created OData service will be exposed for consumption. Such that, this service can be consumed by Mobile Devices, by a receiver adapter (REST Adapter) in PO as well as by UIs within the SAP BPM deployed on AS Java. To expose the OData service as a Gateway service in PO, there are two essential activities to be performed;
- Create HTTP Destination to the Backend System
- Register OData Service in the OData Provisioning Admin
Create HTTP Destination to the Backend System: To create the http destination from SAP PO to the backend system where the OData service resides; perform the following actions;
1.Navigate to the NetWeaver Administrator URL
2. Navigate through the following to Configuration è Destinations
3. Click on the Create button; choose the Hosting System, assign a Destination Name and select the Destination Type “HTTP“:
4.Click on the next option from the wizard and provide the connection information to the SAP Gateway IW_BEP service;
5. Select the following option to access IW_BEP service in the SAP backend and provide the necessary logon credentials;
Click on the finish tab to complete the process of creating the http destination.
6. Additionally, the new created destination can be tested by clicking the Ping Destination button; if the configuration is done properly, the ping operation should return a successful message: “ Successfully connected to HTTP destination CRD with response code 200. Content type text/html”
Register OData Service in the OData Provisioning Administration: Once the http destination to the backend system where the OData service resides has been set up, then we are ready to register our OData service as a Gateway service. To do this, perform the following actions;
1. Navigate to the SAP PO Gateway OData Provisioning Administration via the url below:
NB: It is important to note that these two roles (GW_USER and GW_ADMIN) should be added to your user in order to be able access the OData Provisioning Administration and perform necessary actions
2. Once in the OData service cockpit, select the “Register a New Service”
3. Choose the http backend destination created earlier in the NetWeaver Administrator and do a wild card search, select the OData service created earlier in the Backend system from the list;
4. Click on the service to be registered and select the “Register” option, once this is done successfully, the following message is popped up;
5. The Service Document can be opened to view the details of this service in the browser, the metadata can also be accessed by providing the following information in the URL extension of the service: /$metadata eg;
The metadata URL contains the EDMX (Entity Data Model for XML) which contains the service definition for the OData service.
6. Click on the service name to view all the properties of this gateway service;
After all of the steps above have been performed, the Gateway service is ready and available for consumption by different devices and applications.
Providing an entry point to consume complex enterprise services available in the SAP backend system is possible via the OData service. This extensive article has been able to provide an end-to-end overview of the steps and actions required to create an OData service in a SAP Backend system with the Gateway add-on component installed. It provides an overview on how to expose an OData service in the backend as a Gateway service with the SAP Process Orchestration Java Gateway component. Once this service has been registered, it is available for consumption by devices and applications.