Skip to Content
User Experience Insights
Author's profile photo FIRAT ASAN

Creating OData Services from CDS Views

Hello Blogers and Blog Readers,

Developing with CDS Views and Eclipse, which have completely entered our lives as ABAP Developer, is becoming increasingly indispensable. In this blog, I will tell you how to create a cds view from eclipse and create an Odata service from there.

 

1. We are creating our CDS view.

Right click on the package or Local package that we created and select the new “Other Abap Repository” and Data Definition from CDS.

 

2. We are setting fields for our CDS view.

Then we select any table from se16n and its Fields for our CDS View. I used from the EKKO table; Purchasing Doc. , Company Code, Doc. Category, Document Type, Create Date and Create By fields.

I saved the field titles in my language to show the AS tag.

We can examine the structure of the CDS we have created from se11.

 

3. We add ODATA annotations to our CDS View structure.

 

A yellow warning appears on this line. It says the services are not active. We go to services with the /n/IWFND/MAINT_SERVICE Tcode.

We click on Add Service and find the Service name as same as CDS Name that we created and activate it.

 

4. We activate our CDS without error and warning.

 

4. Finally, we go to the services and test our Odata.

 

Thank you for taking the time to read my blog post.

 

CDS View Code:

@AbapCatalog.sqlViewName: 'ZFRT_S_LR'        //ABAP Interface name , that should be different from view name
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #CHECK   //Access Control
@EndUserText.label: 'CDS View Entity for List Report'

@OData.publish: true
@OData.entitySet.name: 'PODataSet'

define view ZFRT_C_LR as select from ekko   //Data source can be -> Table or existing CDS view 
{ 
    key ebeln as SatinAlmaDokumani,
    bukrs as FirmaKodu,
    bsart as DokumanTipi,
    bstyp as Dokumankategorisi,
    ernam as Olusturan,
    aedat as OluturmaTarihi
    
}

Assigned Tags

      2 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Jelena Perfiljeva
      Jelena Perfiljeva

      This is an outdated approach.

      The DDIC-based CDS views are now considered obsolete. Please take a look at this blog post showing what is the current situation: https://blogs.sap.com/2022/10/24/feature-matrix-data-modeling-with-abap-core-data-services/

      That post talks about version 2022 but view entities are also available in 2020 and have been recommended by SAP. So, unless someone is stuck with a seriously old version, the steps described are not recommended. And for the older versions, there are quite a few blogs available already that were written at the time when it was latest and greatest.

      And using a standard table directly is also not a great idea when standard CDS views exist. Sorry, this blog post is not a good example of pretty much anything.

      Author's profile photo FIRAT ASAN
      FIRAT ASAN
      Blog Post Author

      Thank you for your comment Jelena. All comments are important for me.

      You have rights, there is always better way. But we have many consultants who do not use CDS and still have not installed Eclipse. Many find it confusing and think that it is necessary to go step by step. I think there is a need for blogs at all levels. Please let's not ignore the purpose for which the blogs are written and to what level they are addressed.