Skip to Content
Technical Articles
Author's profile photo Zeshan Shafqat

Create a CDS view with joins using eclipse

Hello SAP Community Members,

My Name is Zeshan Shafaqat. I’m Expert in SAP BI/BW and SAP Analytics Cloud.

I found many peoples having trouble that how can we create a CDS view.
In this Blog, I show you screenshots and code of how can you create a CDS View with joins using eclipse.
If you haven’t installed eclipse then click on the below link of the installation guide.

Eclipse and HANA tools Installation Guide: How can you install Eclipse and HANA Tools for ABAP CDS Views, HANA Modeling, and BW4/HANA Modeling | SAP Blogs

What is CDS View?

CDS stands for Core Data Service which are virtual data models of SAP HANA which allow direct access to underlying tables of the HANA database. SAP CDS Views came into being with SAP’s new programming model. SAP CDS Views aim to push logic from the application server to the client side and database.

 

Let’s Begin to open your Eclipse and Follow the Steps that I write Blow for CDS View creation.

Step1: Login to your development server and add your development Package

Right-click on the favorite package and select add a package

Add%20Your%20Development%20Package

 

A popup window opens and search your development package

 

Step 2: Create Your CDS View Data Definition

After your package is added right click on your package and click on new then click on the “Other ABAP Repository object”.

After clicking on “Other ABAP Repository object” a popup window open then search “Data Definition”.

Select the “Data Definition” object to define your View Name starting with “Z”

After defining your view name create a request to transport it from DEV to QAS and QAS to PRD.

 

Step 3: Select Your CDS View Template

After request creation select prebuild CDS View templates that you want to create a CDS View I select “define view with Join”.

After selecting your template name your @abapCatalog.sqlViewName:’ ‘ the name must be starting with “Z” e.g. ZABC

 

Step 4: Write Your CDS View Code to join tables and fetch data from the Database

Code:

@AbapCatalog.sqlViewName: 'ZCDS_SOD'
@AbapCatalog.compiler.CompareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'Sale Order Detail'
define view ZCDS_SO_DATA as select from vbak
left outer join vbap
    on vbak.vbeln = vbap.vbeln {
    
key vbak.vbeln,
    vbap.matnr,
    vbap.arktx,
    sum(vbap.kwmeng) as Order_Qty,
    vbap.netpr,
    vbap.netwr
    
}
group by
    vbak.vbeln,
    vbap.matnr,
    vbap.arktx,
    vbap.netpr,
    vbap.netwr

After writing your code save and activate your code by using ( CTRL+F3 ) keys and preview data using the F8 key.

 

 

Conclusion

After this, you are able to create your own CDS View without any hesitation

 

If you have any further questions regarding CDS Views then contact me freely.

 

Assigned Tags

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