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: 
Active Participant


The purpose of this blog is to show how HANA Artifact CDS view can exposed as Odata service to consumer.

1 CDS (Core Data Services) Views

CDS(Core Data Service) views  is the newest kid in the block in HANA . It allows you to do much more compared to classical view

  • Push Code to Data  Base layer by allowing queries ,calculations and imperative statements at the DB layer(instead of application service layer)
  • Allows you to add associations with other business entities/tables
  • Annotations to semantically describe your data model

I am not going to get vociferous about CDS because there is enough documentation already available .

Please refer this ABAP on HANA open sap course for more details.

For creating CDS views there are some prerequisites

  • Eclipse should be installed
  • ADT(Abap Development Tools) add on should be installed
  • SAP NetWeaver AS ABAP 7.4 SP05 or higher running on a SAP HANA database SPS6 should be available

The ABAP system in which I am trying is NW7.4 SP8 system

Once we are done with prerequisites , we will create a CDS view .

This CDS view will join tables SNWD_SO(Sales Order) and SNWD_BPA (Business Partner) and find out sum of invoices whose gross amount is greater than 10000000.

@AbapCatalog.sqlViewName: 'ZDDLS_CDS_AGGR'
@EndUserText.label: 'CDS view for aggregation'
define view Zars_Cds_Aggr as select from snwd_so as so
inner join snwd_bpa as bpa
on so.buyer_guid = bpa.node_key
{ key bpa.bp_id as BusinessPartner,
  sum( so.gross_amount ) as  Total_Gross_Amount,
group by
    having sum(so.gross_amount) > 100000000

Here you can see there are two views - The View ZDDLS_CDS_AGGR is DDLS(DDL source view) name which can be viewed in SE11 and this object is integrated with the CTS (Change and transportation system) .The other view ZARS_CDS_AGGR is the CDS view name

Now we will check the results of the CDS Views. We can do it in two ways

a Open Data preview of CDS view in Eclipse

Now the results

b You can see the result in classical se11 transaction also. But this time we should give the DDL SQL view name ZDDLS_CDS_AGGR


2 Data Modelling in Gateway Builder

As we are done with CDS view building , we will move to Gateway data modeling part . The good thing here is we don't need to switch to GUI for Gateway builder transaction. We can run the SEGW transaction from eclipse itself as an embedded GUI. Just press CTRL+SHIFT+A and give SEGW :smile: .

We Create  data model based on DDLS view ZDDLS_CDS_AGGR

Click on Next button

select the properties we want in the entity( ignore the MANDT field)

Here we can see the property names of the entity has been automatically adjusted (Camel case) and we need to mark the Business Partner as the key property of the entity

Press finish to complete the data model part

3 Service implementation

Now we are done with Data model , we look into the data provisioning part.

Here we give the data source name as CDS view name ZARS_CDS_AGGR

Right click on the entity set SalesAggregationSet under service implementation and select Map to Data source . The important point here is we are not mapping the GetEntitySet operation of the entityset but the entityset itself.

We have to select type as Business Entity and use F4 help to select CDS view  ZARS_CDS_AGGR.

We then do the mapping of Entity properties with the CDS view fields. Strangely propose mapping button seems to be not there

Generate the model and do the service registration

4 Testing

Now we head to GW client for testing . We test the SalesAggregationSet.

In the above case we have not implemented the query operation but we use the URL of the query operation to get the CDS view results .

One more thing that comes free is the read operation .No separate implementation of READ :smile: (GET_ENTITY) required.

So if We put the below URL

/sap/opu/odata/SAP/ZARS_CDS_SIMPLE_SRV/SalesAggregationSet('100000014') also, we get the results


ABAP is not only 'ABAP' right now . For a complete End to End scenario , now we need to proficient across three layers (ABAP,Gateway,UI) which seems to be close to impossible .  But as  grey haired 'Abaper' , it is required that we at least keep up to date with  how ABAP is evolving itself for HANA DB and how its pushing the changes  in Gateway layer. The easiest solution will be to ignore all the changes happening around us and stick to the old classical style. But that will be a gap too big to bridge