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.
Step 1: Login to your development server and add your development Package
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.
No comments:
Post a Comment