Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
Showing results for 
Search instead for 
Did you mean: 
Product and Topic Expert
Product and Topic Expert
In my previous articles, I explained what Smart Business Service is and how to subscribe and use Smart Business to create analytic content. In this article I will focus on ABAP CDS view and OData.


One of the common use case for Smart Business Service is consuming ABAP CDS view from S/4HANA system and create analytic content.

Importance of SAP Annotations for OData (OData4SAP)

When you implement your CDS view and OData service in ABAP, make sure that your service supports auto aggregation and provides OData4SAP annotations.

In CDS View we can use “@OData.publish: true” to include annotations. With the annotation, we can find multiple information in $metadata. For example,

  • if an entity type is an aggregate or not

  • If a property is a dimension or measure

  • What is the label and other information of a property

Note: You may refer to this article to know more about SAP Annotations for OData.

Create a CDS View and OData Service with SAP Annotations

Let us see step by step process of creating a CDS view and OData service which provide SAP annotations.

Here we will use SFLIGHT table. SFLIGHT is a standard SAP Table which is used to store Flight information. You can use transaction code SE54 and SE16 to see the table details as below.


You have installed Eclipse IDE and installed ABAP Development Tools in Eclipse IDE. Refer to this link for more details.


Step 1: Create a CDS View

Create a CDS view using SFLIGHT table. For detail steps on creating CDS view, check this link.

Use the below code snippet to create CDS view.
@AbapCatalog.sqlViewName: 'SBS_FLIGHT_SVIEW'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'sflight table as view'
@OData.publish: true

define view SBS_SFLIGHT_VIEW
as select from sflight
// KEY Fields
key sflight.carrid as AirlineCode,
key sflight.connid as FlightConnectionNumber,
key sflight.fldate as FlightDate,

sflight.planetype as AircraftType,
sflight.mandt as Client,
sflight.price as Airfare,

@DefaultAggregation: #SUM
sflight.paymentsum as TotalBookings


Make sure you insert following OData annotation to the CDS view:

 @OData.publish: true


Step 2: Activate OData Service in the SAP Gateway Hub

Now you need to activate the OData service in the SAP Gateway hub. Refer to this link to know detail step of this.


Test the Activated OData Service and use $metadata parameter to check metadata and annotation information. The output should looks like below.


What’s next?

Now your OData is ready to be used in Smart Business Service. All you need to do is configure HANA Cloud Connector and create KPI and Tiles using the OData. This is similar to on-premise to Smart Business connection explained in the blog Connect On-Premise HANA to Smart Business Service – An End-to-End Example.


Note: A complete implementation guide on Smart Business Service is also available at SAP-Press.