Maybe you heard the announcement of the new application programming model for SAP Cloud Platform at SAPPHIRE NOW 2018 and read the
introduction from Daniel Hutzel.
Additionally you read the
blog from Yuval Anafi about how to develop a business application based on the new programming model with SAP Web IDE.
Now, you might wonder whether there is a sample application available showcasing the major benefits of the new application programming model and giving you the opportunity to try it out in SAP Web IDE?
If yes, this blog could be of interest for you.
The structure of the sample
One central aspect of the application programming model for SAP Cloud Platform is the focus on making it easy to reuse and extend existing data models.
Foundation
When implementing business applications, you always rely on the same basic code lists, like currency and unit of measure. You don’t want to model them yourself. On the other hand, they should be part of your application and not require another service.
With the
foundation model we provide a sample on GitHub.com demonstrating how such a common reuse model could look like using Core Data and Services (
CDS).
The foundation reuse model is exposed with its public API being declared by an
index.cds file.
Product Catalog
As consuming business application, we introduce a simplified
product catalog, which allows to display, create, delete and modify product master data. The focus of this sample is not on the business functionality, but on how to develop a business application in general and particularly how to reuse CDS models. For more detailed information about the implementation of business applications you should read this
documentation.
Daniel shows in the section
Key Ingredients of his
blog the three different components of a business application. This applies to the structure of the sample application as follows.
- The user interface is based on SAP Fiori Elements. A developer selects a floorplan, in our case a list report and an object page. Here you can find the corresponding module in the sample. To define the appearance and behavior of the UI, the developer adds CDS annotations to the service and data model.
- The service provider consists of a generic OData V2 provider that automatically serves metadata and CRUD requests. A developer can add custom logic. Such a custom handler implementation in Java can be found here as part of the sample.
- From the data model the data base tables are generated, in our case for deployment to SAP HANA. This is the sample DB module.
The foundation reuse is done by declaring a dependency to the foundation model in the
package.json of the product catalog.
Whenever a definition or even the whole exposed content of the foundation model is needed, it can be imported by the
using directive.
The diagram below shows the dependencies between foundation and product catalog as well as the dependencies within the two components.
ITelO Catalog
Another important aspect is the project-level extension of a data model.
Let’s assume a development team of the fictitious company ITelO needs to implement a product catalog. Looking through available CDS reuse models, they found the product catalog model from above. As an extra requirement, the team needed to include product reviews as an additional source of information for the editor of the product catalog. Unfortunately, reviews are not modeled in the product catalog. Thanks to the application programming model for SAP Cloud Platform they could solve this issue by simply extending the model with additional review entities.
You might have noticed that the product catalog is a standalone application and at the same time a reuse model.
Just like in the scenario before, the
ITelO catalog now reuses the product catalog and adds additionally the review aspect. The latter is done by
extending the service model with a Reviews entity, but how to access this entity from a product? Therefore, it is necessary to extend the Products entity by an
association to Reviews. Also
field extensions are possible.
The design time dependencies of the ITelO application are depicted in the diagram below. During run time the application consists of a
DB module, a
service module and a
UI module.
Development in SAP Web IDE
Enough theory. Let’s get the ITelO sample build and deployed. For that purpose it is recommended to read the
getting started tutorial, especially the
prerequisites. At this point in time you should have access to SAP Web IDE.
If you want to play around with the sample, you can fork the GitHub repository of
ITelO. After starting SAP Web IDE clone your fork (
File→ Git→ Clone Repository) and switch to branch
rel-1.0 (
Git Pane→ Create Local Branch→ Source Branch→ origin/rel-1.0).
In case you also want to modify the reuse models, make sure that you replace the GitHub dependencies in the package.json of your consumption project by your own fork.
To build and deploy the application or modify it and redeploy, use any of the following options:
- Build and deploy the DB module by choosing Build from the context menu of the db folder. You should get the following message toast.
- Build and deploy the Java service by choosing Run→ Run as→ Java application from the context menu of the srv folder. To test the service, click the URL displayed in the run console. Use the endpoint of the service clouds.products.CatalogService to call $metadata or CRUD requests.
- Test the UI by choosing Run→ Run as→ SAP Fiori Launchpad Sandbox from the context menu of the app folder. Click on the app tile to launch the application. The result should be similar to the picture below.
Of course, this blog is not able to cover all questions, neither on the new application programming model for SAP Cloud Platform nor on the sample code. So, watch out for additional blogs.