Skip to Content
Technical Articles

Developing APIs with Cloud Application Programming(CAP) Model

Motivation

A lot has already been said about the Cloud Application Programming Model(CAP) for SAP Cloud Platform.CAP provides an easy way to build Business Applications on SAP Cloud Platform within an SAP ecosystem. The following links provides more information on CAP and how it benefits for Developers developing applications on SAP Cloud Platform.

https://blogs.sap.com/2018/06/05/introducing-the-new-application-programming-model-for-sap-cloud-platform/

This blog is going to describe the way how the CAP can be leveraged in creating an API-as-a Service Scenario. Consequently we are also going to see how this API can be managed using SAP API Management .

 

Story

Org_X is into Health Business and is trying to leverage the data already captured in its Back-end systems. Therefore it decides to expose these data to the developers , so that the data becomes valuable to them. The exposing of the data would be in the form of HTTP APIs for the scenario Nutrient-As-A-Service. These APIs would become the building blocks for its business. The APIs would attract Developers and once the Developer finds value in the APIs , Org_X expects to monetise these APIs as well.

In order to achieve this goal, Org_X decides to create Application on SAP Cloud Platform using Cloud Application Programming Model. For Managing, Metering, Monetising and Developer Onboarding Org_X decides to use SAP API Management- which lets API Provider and API Consumer come under the same platform and engage.

 

Develop Nutrient-As-a-Service using Cloud Application Programming Model(CAP)

As pre-requisite follow this blog to install Cloud Foundry Builder

  1. In SAP Web IDE choose File | New | Project from Template.
  2. Select Business Application as the Template
  3. Provide the Application Details
  4. Define the Data Model indb/data-model.cds
    namespace nutrientservice;
    
    entity nutrientinfo {
        name:String(255);
        grouping:String(255);
        protein:Double;
        calcium:Double;
        sodium:Double;
        fiber:Double;
        vitaminc:Double;
        potassium:Double;
        carbohydrate:Double;
        sugars:Double;
        fat:Double;
        water:Double;
        calories:Double;
        saturated:Double;
        monounsat:Double;
        polyunsat:Double;
        key id:Integer not null;
    }​
  5. Define the Service- Go to srv/my-service.cds and open the context menu.
    using nutrientservice.nutrientinfo as nutrientserv from '../db/data-model';
    service NutrientService{
        entity nutrientinfo as projection on nutrientserv;
    }​
  6. Save the Project and Run the Service
  7. Once the Service is run , use the Cloud Foundry option to Deploy the application to Cloud Foundry.
  8. The Application is Now deployed in Cloud Foundry and the API is ready to be Governed, metered and Monitored.

 

Check out the following blog on how to Govern, Meter and Monetise this API using SAP API Management.

https://blogs.sap.com/2017/08/23/data-as-service-monetize-your-api-part-22/

Be the first to leave a comment
You must be Logged on to comment or reply to a post.