6

Create a CDS view with joins using eclipse

 1 year ago
source link: https://blogs.sap.com/2022/10/07/create-a-cds-view-with-joins-using-eclipse/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
October 7, 2022 3 minute read

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

02-Search-Pacakge-.png

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”.

03-add-CDS-View.png

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

04-search-DATA-Defination.png

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

05-NAme-your-CDS-View-.png

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

06-Create-Request.png

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”.

07-select-CDS-Type.png

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

08-CDS-View-Templete.png

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

09-sample-Code.png

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.

10-Data-previwe.png

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.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK