Any coding or configuration examples provided in this document are only examples and are NOT intended for use in a productive system. The example is only done to better explain and visualize the possibilities with SAP Cloud Offerings.
In this blog I want to share how to extend SAP S/4 HANA solution (On-Premise) by leveraging SAP Cloud Platform. We will see how to expose S/4 HANA Utilities objects on SAP Cloud Platform as a simple UI5 application. The backbone of this exercise is Core Data Services (CDS).
CDS simplifies and harmonizes the way you define and consume your data models, regardless of the consumption technology. Technically, it is an enhancement of SQL which provides you with a data definition language (DDL) for defining semantically rich database tables/views (CDS entities) and user-defined types in the database. Some enhancements include:
- Expressions used for calculations and queries in the data model
- Associations on a conceptual level, replacing joins with simple path expressions in queries
- Annotations to enrich the data models with additional (domain specific) metadata
Scope of the blog
- Create a CDS View to expose Service Notifications from an S/4 HANA Utilities system.
- Expose the CDS View as OData service.
- Consume the CDS View in a simple UI5 Application built on SAP Cloud Platform.
For the purpose of this blog, we take the example of Service Notifications. At the end of this blog, we would be pulling data from S/4 HANA Utilities system and showing it as a Fiori worklist application.
Creating a CDS View in ABAP Development Toolkit (ADT)
- Start ABAP in Eclipse : First, we need to start ABAP in Eclipse, which is a plug-in tool for ABAP development that you install in your Eclipse workspace. SAP’s Eclipse-based plugins, including ABAP in Eclipse, are available from its tools update site (https://tools.hana.ondemand.com). In this example we use $TMP to house the CDS artifact. Simply right-click on the package icon, and from the context menu select New > Other ABAP Repository Object.
- Create a new CDS View : In the New ABAP Repository Object pop-up, search for Data Definition Language. Select $TMP as the package (No transport details required).
- Select a Template for the CDS View: The last screen of the New DDL Source wizard offers a selection of templates for creating a CDS view, including a display of the default syntax provided with each.
- Write the logic for CDS View: For the purpose of this blog, we have taken a simple example for Service Notification. The CDS view is created on top of a standard view – viqmel which holds some data related to Notifications. Once the DDL logic is complete, activate the CDS artifiact.
Expose CDS View as an OData service
- Using the new ABAP programming model we can leverage an out-of-the-box OData V2 support. By simply adding the annotation @OData.publish:true in the CDS consumption view an OData V2 service is generated in the SAP Business Suite or S/4 HANA backend that can be published in the SAP Gateway Server. More information available on the following link – Expose CDS View as an OData Service
- Once the OData service is created, it needs to be activated in order to be available for consumption. The following link explains how to activate a service in Gateway Hub (Available out of the box for S/4 systems) – Activate OData Service in the SAP Gateway Hub. Once activated, the service should be available in Service Catalog. Click on Call Browser to see the service URL.
Consume OData service in SAP Cloud Platform
The Connectivity service allows SAP Cloud Platform applications to securely access remote services that run on the Internet or on-premise. The Cloud Connector serves as a link between SAP Cloud Platform applications and on-premise systems. It combines an easy setup with a clear configuration of the systems that are exposed to the SAP Cloud Platform. To connect to S/4 on-premise system from SAP Cloud Platform, a cloud connector is necessary.
The following links give a good detail about Cloud Connector, Installation, Configuration and its usage :
- SAP Cloud Platform Cloud Connector – A Brief Guide for Beginners
- SAP Cloud Platform Cloud Connector – SAP Help Page
Once the cloud connector is set up, we can configure destinations to connect to backend on-premise systems. Destinations offer different authentication mechanisms like Basic Authentication, OAuth2SAMLBearerAssertion, Principal Propagation etc.
Web IDE full stack can be used to quickly create UIs consuming the destination created above. For the purpose of this blog, we would create a Fiori Worklist Application.
- Go to you SAP Cloud Platform Neo Account and open Web IDE Full Stack from Services. Create a new Project from Template.
- From the Template Selection screen, select SAP Fiori Worklist Application.
- Enter the basic details.
- In the Data Connection tab, go to Service URL and select the destination configured before. Also give the relative path for the OData service created in S/4 system and click on Test. In this case it would be : sap/opu/odata/sap/Z_SERV_NOTIFICATION_VIEW_CDS
- Select the Application Type and give the Binding information. Click on Finish.
- Once created, a worklist application gets in the workspace. Enhance the worklist.view.xml and object.view.xml to add more fields and maintain proper bindings. Furthermore the controller can be enhanced to enable filter on Customer ID to fetch details for a particular customer.
Right click on your project to deploy to SAP Clloud Platform.
Finally, after following the above mentioned steps, we have the application ready:
As you can see, the Side-by-Side Extensibility allows you to build external apps in the SAP Cloud Platform to read from or post data to your SAP S/4 HANA solution.