Skip to Content
Technical Articles
Author's profile photo Pavan Kumar Reddy

ABAP on SAP Cloud Platform – ABAP Restful Programming Model

In this blog I am going to explain steps to develop Odata service based on ABAP on SAP Cloud Platform architecture using ABAP Core Data Service (CDS) views. The architecture overview is as follows:

In the above architecture from the left figure bottom to top you can see steps to develop the service and consume it in Fiori or other front end applications.

  1. Data Modeling and Behavior
  2. Business services Provisioning
  3. Service consumption

1. Data Modeling and Behavior

Here modeling of CDS, Behavior definition and behavior implementation happens.

Behavior definition:  A behavior definition is defined using the Behavior Definition Language (BDL) and comprises capabilities and modelling aspects of the business object node or nodes, for example the supported operations (such as create, update, and delete actions) or the definition of lock dependencies between the parent and child nodes. In short behavior definition is used for transaction processing of an application.

Behavior Implementation:  Here implementation of create, update, delete etc methods of behavior definition happens in ABAP Class.

2. Business services provisioning:

Here service definition and  service implementation takes place:

Service definition: The service definition is a projection of the data model and the related behavior to be exposed.

Service Binding: The service binding implements a specific protocol and the kind of service to be offered for a consumer.

Service definition has one or more service bindings. You can use a service definition only in connection with at least one service binding.

3. Service consumption: 

Service consumption in the form of OData is consumed in Fiori or other front end applications.

Lets start developing an OData service for List Reporting based on the ABAP RESTful Programming model. I am using flight data model for Building the oData service.

Step1. Creating Data Definition for a CDS View:

For how to create CDS view refer blog

@AbapCatalog.sqlViewName: 'ZICONRPM'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Data Model of Flight Connections'
@UI.headerInfo.typeNamePlural: 'Connections'
@UI.headerInfo.typeName: 'Connection'
define view zi_con_rpm
  as select from /dmo/connection as Connections

      @UI.lineItem: [ { position: 10 } ]
  key carrier_id      as CarrierID,

      @UI.lineItem: [ { position: 20 } ]
  key connection_id   as ConnectionID,

      @UI.lineItem: [ { position: 30 } ]
      @UI.selectionField: [ { position: 10 } ]
      airport_from_id as DepartureAirport,

      @UI.lineItem: [ { position: 40 } ]
      @UI.selectionField: [ { position: 20 } ]
      airport_to_id   as DestinationAirport,

      @UI.lineItem: [ { position: 50 } ]
      departure_time  as DepartureTime,

      @UI.lineItem: [ { position: 60 } ]
      arrival_time    as ArrivalTime,

      @Semantics.quantity.unitOfMeasure: 'DistanceUnit'
      distance        as Distance,

      @Semantics.unitOfMeasure: true
      distance_unit   as DistanceUnit


In above source code “zi_con_rpm” is the CDS view selects data from  data source “/dmo/connection

Step 2. Creating a service definition and expose CDS view for an OData service

Service definition defines the scope of OData service. In a service definition, you define the OData service to determine which CDS entities are part of the service. Use service definition wizard to create service definition as below:

Select service definition under node business services

Give name of the service definition and click on finish

add source code as below in the service definition:

@EndUserText.label: 'Service Definition for Managing Flights'
define service Zflight_sd_rpm {
  expose zi_con_rpm as Connections;

In the above source code “Zflight_sd_rpm” is the service definition name and “zi_con_rpm” is the CDS entity which is created in step1, this needs to be exposed for Odata service with keyword expose. This how you assign the scope of the OData service

one or more CDS entities can be exposed in the service definition.

Step 3. Creating a Service Binding

Service binding implements the protocol that is used for the OData service. It uses a service definition that projects the data models and their related behaviors to the service.

Using below wizard you can create service binding for service definition created in Step 2

Select Service Binding and click on Next:

Give name of Service Binding and service definition name for which binding needs to be created and click on Finish

In above “ZFLIGHT_SB_RPM”  is the service binding for service definition “ZFLIGHT_SD_RPM” created in Step 2.

The ABAP back end creates a service binding and stores it in the ABAP Repository.In the Project Explorer, the new service binding is added to the Business Services folder of the corresponding package node.

Click on the button Publish as shown below to publish Odata service locally which makes service ready for consumption

Odata service “ZFLIGHT_SD_RPM”  published locally and  on the left side of the form editor, the service list with the name, version of the OData V2 service is filled. The right side of the form editor shows the service information and lists the entity sets that are exposed for the service.

Double click on service URL on the left side to launch service URL in browser to verify the OData Metadata

Metadata of the service “ZFLIGHT_SB_RPM” can be viewed in the browser.

In order to preview the resulting UI service in Fiori Elements app view double click on the entity set Connections or right click to the context menu as shown below:

User interface for a Fiori elements app can viewed for OData service:

Before releases in order to view the results of modeled CDS view you need to go to WebIDE and create a project for smart template Fiori app and give OData service to view the List Report application but in the latest release of ABAP on SAP Cloud Platform  a plugin is configured to see the result preview of SAP Fiori Elements App.

The above steps guide you how to create read(R) only application by using Business Services Provisioning  (Service Definition and Service Binding ). In my next blogs I will show how to create transaction CUD application by using Data Modeling and Behavior ( Behavior definition and Behavior Implementation )

Hope you find this blog helpful.

Other Blogs which might be interesting for you regarding future of SAP application programming:

The future of SAP application programming according to TechEd 2018




Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Nabheet Madan
      Nabheet Madan

      Thanks Pavan for good blog.  Looking forward to the next one.

      Author's profile photo Paul Hardy
      Paul Hardy

      The above blog is very, very similar to the official SAP documentation on the subject.... that being said it is a lot more compact, and thus easier to understand.

      Author's profile photo Sebastian Freilinger-Huber
      Sebastian Freilinger-Huber

      Thanks for linking my blog 🙂


      Looking forward to see the model conquering the On-Premise world!

      Author's profile photo Javier Exposito Gonzalez
      Javier Exposito Gonzalez

      Nice Blog, thanks for sharing the knowledge...


      Author's profile photo Shani Niza
      Shani Niza

      Hi Pavan, can you please help me on how this can be done? "In my next blogs I will show how to create transaction CUD application by using Data Modeling and Behavior ( Behavior definition and Behavior Implementation )"

      Author's profile photo Pavan Kumar Reddy
      Pavan Kumar Reddy
      Blog Post Author

      Hi Shani

      Sorry for late reply.

      You can go through tutorial "Create Core Data Services with ABAP Environmentwhich has "Add Transactional Behavior to Your Core Data Services"  explains transaction (CUD) application by using behavior definition and behavior Implementation.




      Author's profile photo Sunil Panigrahi
      Sunil Panigrahi

      Very nice..waiting for your upcoming topics..