SlideShare a Scribd company logo
Core Data Services
(CDS) May 19th, 2017
Meet The Speaker
Jonathan Andre
Lead Developer
IT Partners
Our Agenda
About CDS / How to Create
Basic ABAP CDS View
Other Features ABAP CDS
HANA CDS and Native SQL
What is CDS?
• Core Data Services, or CDS, is a “semantically rich” Data Definition Language (or DDL)
created by SAP. It provides an easy to understand and reusable tool that ABAP
developers can utilize to execute the “code pushdown” paradigm.
• CDS comes in different flavors , a HANA version and an ABAP version:
• HANA CDS - The lesser used option for ABAP coders is HANA CDS, the database
language that can be used to create tables, views, and structures on the HANA
database itself. Views created in HANA can be consumed from the Netweaver AS
using Native SQL.
• ABAP CDS – This is the CDS flavor that will almost be exclusively used in most SAP
business software systems. ABAP CDS is usually the best choice when designing
and creating database views that will need to access the HANA database.
What is CDS?
• ABAP CDS, made available with SAP Netweaver 7.40 SP5, allows coders to achieve the “code-to-data”
programming paradigm using a reusable resource that can be used across different programs and
projects.
• “Code-to-data”, also sometimes referred to as “code-pushdown” is the process of moving data intensive
programming logic from the application later down to the database layer.
• CDS achieves these primarily through the use of “Views”, however the views in the context of CDS go
beyond those classical SE11 since much of the logic previously left to the programming level (i.e. ABAP
program logic) can now be outsourced to the database level.
• Although CDS performs well with the HANA database and takes advantage of many of its features, it is
actually an OPEN DDL (data definition language) language. The term Open meaning that it will work
with all traditional databases that can be used to run the latest versions of the SAP NetWeaver
products.
• An ABAP CDS file can ONLY be create within the Eclipse IDE (there is no transaction to do this from SAP
GUI). CDS files are written in an augmented form of SQL Script
Creating First CDS View (Using AWS)
Creating First CDS View (Using AWS)
Creating First CDS View (Using AWS)
Creating First CDS View (Using AWS)
Creating First CDS
View (Using AWS)
Opening Annotations – These declare high
level data about the CDS view:
• @AbapCatalog.sqlViewName is the only
mandatory annotation for a non-
extending CDS View source file.
• @AbapControl.authorizationCheck
specifies whether an authorization check
should be performed for the current CDS
view.
Creating First CDS
View (Using AWS)
Datasource Declarations-
This section will come after the opening
Annotations, but before the first curly
bracket. Within this section, the developer
specifies:
• the type of view (define or extend view)
• the CDS view name (in this case
ZJON_CDS_VIEW_EXAMPLE),
• the source table or view (SNWD_SO)
• Any parameters (more on this later)
• Any joins/associations (more on this later)
Creating First CDS
View (Using AWS)
Field Declarations and Specifications
• After the first curly bracket comes the
desired fields from the table, as well as
any fields that are to be computed.
• This is the section that a developer will
primarily utilize to take advantage of
code-pushdown.
• The CASE function allows a particular
value to be returned based on the value
of a table field.
• We define the field returned as
‘payment_status’. To the calling program,
there’s no difference between this
generated field and a regular database
field.
Creating First CDS
View (Using AWS)
Select Conditions, Restrictions, and
Grouping Declarations
The last section of the DDL source file is
where you would add any selection
restrictions (such as a where clause) in
addition to any aggregation instructions
(such as GROUP BY). We will be covering
both of these options in later examples.
Previewing a CDS View
• CDS Views can be previewed right within
the Eclipse editor. To do this, right-click on
the created view, select “Open With” and
then select “Data Preview” from the
submenu. (Note that in other versions of
the ABAP Development Tools, the “Data
Preview” option may appear immediately
in the menu when you right click.)
• Notice that, along with the data we have
selected from the snwd_so table, we also
have the calculated field payment_status
that was created using the CASE function.
What happens on the
HANA DB?
• When you create an ABAP CDS View, a
corresponding view is created on the
HANA DB matching the CDS view created
on the ABAP side.
• This view will have the SQL View name
that you provided (after the
@AbapCatalog.sqlViewName annotation)
and will be generated automatically after
you create the CDS view.
• The corresponding HANA view does not
require a separate transport to move
between HANA DBs. Once the view is
transported and executed on SAP
NetWeaver, the HANA View will be
generated automatically in the
corresponding HANA DB.
• You can view the create SQL view in
Eclipse by using the SQL HANA
Administrator Perspective (described on
the next slide).
What happens on the
HANA DB?
1 – Open the SAP HANA Administrator
Console
2 – Log into the HDB system (password
should be the same one for all
usernames/windows login.
3 – Open the Catalog folder
4 – Navigate to the SAPA4H schema (which
holds all tables/views for SAP NetWeaver)
5 – Click find table and type the
sqlViewName you used for your first view (or
any other CDS view you’ve created).
NOTE: Theres no requirement that his SQL
View name be the same as your CDS view
name! This SQL view name will be in the
annotations section.
What happens on the
HANA DB?
Double click on the SQL View name
corresponding to your CDS view, and you
should see a display with two tabs.
The first tab, Columns, displays the columns
that are available with your CDS View.
The second tab shows the SQL statement for
your view, which should look familiar. It
should be nearly identical to the CDS View
you coded on the NetWeaver side, with a few
syntax adjustments to make it compatible
with the HANA DB.
Using a CDS View in an
ABAP Program
Using a CDS view simply requires using an
Open SQL statement that selects from our
CDS Entity (ZJON_CDS_VIEW_EXAMPLE). As
an added benefit of ABAP CDS, a generated
CDS Entity name can also be used in DATA
declarations to create structures of a
compatible TYPE:
Associations
Associations are essentially reusable JOINS
that relate two CDS Entities (tables or views)
to each other. CDS Associations have the
added benefit of being able to specify
cardinality ([1..1], [0..1], [*], etc.). Many of
the features of ASSOCIATIONS are available
as JOINS, however ASSOCIATIONS are the
preferred and more elegant option when
merging two CDS entities.
Aggregate Functions
The aggregate functions available in CDS Views
are the same ones that are available in the new
Open SQL. Although they are readily available
during a regular Open SQL Select, it is still an
extremely useful tool to have in CDS Views.
Using the CDS approach, developers can make
certain summary data uniform across projects
and systems without having to maintain entirely
separate summary level tables. As you can see
in the above example, any time you use these
aggregate functions in the field declaration
section, you are required to include the GROUP
BY addition in the Selection Restriction and
Condition section.
Removing the GROUP BY clause while having
either of these functions remaining will raise a
syntax error, which is logical since you cannot
have summary level data item level records.
Aggregate Functions
The data preview shows that, instead of
showing every single SO in the system, we
are now showing the data summarized by
company.
Using our CDS View with aggregate functions
allows your us to view every company with
unpaid sales orders with gross amounts over
$500, who many of these sales orders they
have, and the total gross amount of the sales
orders.
Before HANA, a calculation like this would
require selecting all this data into an internal
table, looping through the documents one by
one, and keeping track of totals.
Using CDS/HANA we can view this data much
faster with all the work already completed
for us!
CDS View Parameters
• CDS Views also allow for parameters to
be used to help in building more dynamic
views.
• Parameter can be used to provide
variable conditions to search conditions
(similar to what one would achieve by
using a WHERE clause.
• Parameters can also be used to provide
values for CASE statements, arithmetic
calculations when calculating fields, and
performing other alterations to functional
operations that would not be possible
with a classical SELECT statement.
• All CDS Parameters are MANDATORY.
Using CDS Views with
Parameters
• To use the parameters in a SELECT
statement, you would need to use
parentheses after immediately following
the CDS View name. This is similar to how
you would pass parameters to a method
call.
• You can use variable values in the
parameters by using the ‘@’ symbol
before the variable name (which is
common the new Open SQL syntax).
• If you prefer to use hard coded strings or
values instead, the ‘@’ is not required.
Extending Views
• Existing CDS Views can also be
“enhanced” by creating a separate
Extend View that contains additional
fields you would like to include.
• For instance, in this example we
would like to extend our original
view ZJON_CDS_VIEW_EXAMPLE.
• To do this we create a NEW view
ZJON_VIEW_EXAMPLE_PAID_EXTND
as shown to the right.
• This will EXTEND the original view
and add the field “so_status”.
• This is useful when trying to modify
views original created by SAP with
customs fields.
Extending Views
The original views source code will be
modified with a familiar icon, which indicates
it has been extended by another view
Creating a HANA CDS
View (Prerequisite)
If you try to create a HANA CDS View with
the default settings, you will get a strange
encoding error. Update your workspace
settings BEFORE creating your HANA CDS
View (or you will have to delete it and
restart)
Follow the menu path:
Window->Preferences->General
With the general section expanded, click on
the Workspaces text.
Change your encoding from the default
cp1252 to UTF-8 (under other)
Creating a HANA CDS
View
• Click the New Perspective icon in the top
right of the window (to the left of the
ABAP icon)
• Locate the SAP HANA Development
perspective and hit OK.
Creating a HANA CDS View
2 – Click the “Systems” Tab
3- Double click the HDB system
4 – Enter your password (same as password
for everything else)
1- Ensure you are in the SAP HANA
Development Perspective(it looks very
similar to the ABAP Perspective)
Creating a HANA CDS View
• While still in the SAP HANA
Development Perspective, navigate to
the Project Explorer tab (you will still
see your ABAP projects listed, which is
fine)
• Right click in the white space, then
navigate to New->Project…
• Follow the menu path SAP HANA-
>Application Development then click
XS Project
• Give the project a name (for the
source code to work as provided the
name must be ZJON_CDS )
• Select the Default workspace
• Deselect the to access objects and hit
finish.
Creating a HANA CDS View
• Right click on the new project, the
navigate to New->Other
• Then navigate to SAP HANA->Database
Development-> DDL Source File
Creating a HANA CDS View
• Enter the desired name of your CDS
View (it must be ZJON_CDS for the
source code to work)
• Select the project that was just created
• Hit Finish
Creating a HANA CDS View
• To the right is an example CDS view.
You will notice that it does not have
the same annotations as the ABAP CDS
view.
• Instead, it does have the namespace
keyword followed by the project name.
• In addition, it has an @Schema
notation followed by the schema that
will be used (this should match the
schema that contains your database
tables, in this case SAPA4H.
• Lastly, note that the field names MUST
BE CAPITALIZED (or the code will no
compile, leaving you with a very
confusing error message)
• While this HANA CDS view is still
selected, hit the green arrow to
activate this CDS view
Creating a HANA CDS
View
• To utilize a HANA CDS View, a Native
SQL call is required. This is because the
ABAP Data Dictionary has no
knowledge of this view since it was
defined outside of the NetWeaver AS.
• Native SQL can be extremely finicky,
and debugging any issues can be
extremely difficult.
• Compare this code to the first CDS
view in terms of complexity,
maintainability, and flexibility. Its clear
to see why ABAP CDS is always the
better option, unless there is some
feature that is only accessible through
HANA CDS.

More Related Content

What's hot

Introduction to SAP Gateway and OData
Introduction to SAP Gateway and ODataIntroduction to SAP Gateway and OData
Introduction to SAP Gateway and OData
Chris Whealy
 
Beginner's Guide: Programming with ABAP on HANA
Beginner's Guide: Programming with ABAP on HANABeginner's Guide: Programming with ABAP on HANA
Beginner's Guide: Programming with ABAP on HANA
Ashish Saxena
 
SAP ABAP - Needed Notes
SAP   ABAP - Needed NotesSAP   ABAP - Needed Notes
SAP ABAP - Needed Notes
Akash Bhavsar
 
Abap package concept
Abap package conceptAbap package concept
Abap package concept
Tobias Trapp
 
Object oriented approach to ALV Lists in ABAP
Object oriented approach to ALV Lists in ABAPObject oriented approach to ALV Lists in ABAP
Object oriented approach to ALV Lists in ABAP
Noman Mohamed Hanif
 
Sap sapscripts tips and tricks
Sap sapscripts tips and tricksSap sapscripts tips and tricks
Sap sapscripts tips and tricksKranthi Kumar
 
Ab1011 module pool programming
Ab1011   module pool programmingAb1011   module pool programming
Ab1011 module pool programming
Satheesh Kanna
 
Introduction to ABAP
Introduction to ABAPIntroduction to ABAP
Introduction to ABAP
sapdocs. info
 
Table maintenance generator and its modifications
Table maintenance generator and its modificationsTable maintenance generator and its modifications
Table maintenance generator and its modifications
scribid.download
 
SAP ABAP Latest Interview Questions with Answers by Garuda Trainings
SAP ABAP Latest Interview Questions with Answers by Garuda TrainingsSAP ABAP Latest Interview Questions with Answers by Garuda Trainings
SAP ABAP Latest Interview Questions with Answers by Garuda Trainings
Garuda Trainings
 
Chapter 02 sap script forms
Chapter 02 sap script formsChapter 02 sap script forms
Chapter 02 sap script formsKranthi Kumar
 
SAP ABAP data dictionary
SAP ABAP data dictionarySAP ABAP data dictionary
SAP ABAP data dictionary
Revanth Nagaraju
 
Introducing enhancement framework.doc
Introducing enhancement framework.docIntroducing enhancement framework.doc
Introducing enhancement framework.docKranthi Kumar
 
BRF+ Walk through
BRF+ Walk throughBRF+ Walk through
BRF+ Walk through
Dhivya Baskaran
 
0104 abap dictionary
0104 abap dictionary0104 abap dictionary
0104 abap dictionary
vkyecc1
 
Oops abap fundamental
Oops abap fundamentalOops abap fundamental
Oops abap fundamental
biswajit2015
 
SAP BADI Implementation Learning for Functional Consultant
SAP BADI Implementation Learning for Functional ConsultantSAP BADI Implementation Learning for Functional Consultant
SAP BADI Implementation Learning for Functional Consultant
Ankit Sharma
 
Sap abap
Sap abapSap abap
Sap abap
Jugul Crasta
 

What's hot (20)

Introduction to SAP Gateway and OData
Introduction to SAP Gateway and ODataIntroduction to SAP Gateway and OData
Introduction to SAP Gateway and OData
 
Beginner's Guide: Programming with ABAP on HANA
Beginner's Guide: Programming with ABAP on HANABeginner's Guide: Programming with ABAP on HANA
Beginner's Guide: Programming with ABAP on HANA
 
SAP ABAP - Needed Notes
SAP   ABAP - Needed NotesSAP   ABAP - Needed Notes
SAP ABAP - Needed Notes
 
Abap package concept
Abap package conceptAbap package concept
Abap package concept
 
Object oriented approach to ALV Lists in ABAP
Object oriented approach to ALV Lists in ABAPObject oriented approach to ALV Lists in ABAP
Object oriented approach to ALV Lists in ABAP
 
Sap sapscripts tips and tricks
Sap sapscripts tips and tricksSap sapscripts tips and tricks
Sap sapscripts tips and tricks
 
Sap scripts
Sap scriptsSap scripts
Sap scripts
 
Ab1011 module pool programming
Ab1011   module pool programmingAb1011   module pool programming
Ab1011 module pool programming
 
Introduction to ABAP
Introduction to ABAPIntroduction to ABAP
Introduction to ABAP
 
Basic Debugging
Basic DebuggingBasic Debugging
Basic Debugging
 
Table maintenance generator and its modifications
Table maintenance generator and its modificationsTable maintenance generator and its modifications
Table maintenance generator and its modifications
 
SAP ABAP Latest Interview Questions with Answers by Garuda Trainings
SAP ABAP Latest Interview Questions with Answers by Garuda TrainingsSAP ABAP Latest Interview Questions with Answers by Garuda Trainings
SAP ABAP Latest Interview Questions with Answers by Garuda Trainings
 
Chapter 02 sap script forms
Chapter 02 sap script formsChapter 02 sap script forms
Chapter 02 sap script forms
 
SAP ABAP data dictionary
SAP ABAP data dictionarySAP ABAP data dictionary
SAP ABAP data dictionary
 
Introducing enhancement framework.doc
Introducing enhancement framework.docIntroducing enhancement framework.doc
Introducing enhancement framework.doc
 
BRF+ Walk through
BRF+ Walk throughBRF+ Walk through
BRF+ Walk through
 
0104 abap dictionary
0104 abap dictionary0104 abap dictionary
0104 abap dictionary
 
Oops abap fundamental
Oops abap fundamentalOops abap fundamental
Oops abap fundamental
 
SAP BADI Implementation Learning for Functional Consultant
SAP BADI Implementation Learning for Functional ConsultantSAP BADI Implementation Learning for Functional Consultant
SAP BADI Implementation Learning for Functional Consultant
 
Sap abap
Sap abapSap abap
Sap abap
 

Similar to CDS Views.pptx

SITIST 2015 Dev - Abap on Hana
SITIST 2015 Dev - Abap on HanaSITIST 2015 Dev - Abap on Hana
SITIST 2015 Dev - Abap on Hana
sitist
 
Sap hana on technical level By Yogesh Gupte
Sap hana on technical level By Yogesh Gupte Sap hana on technical level By Yogesh Gupte
Sap hana on technical level By Yogesh Gupte
yogeshgupte1977
 
SSDT unleashed
SSDT unleashedSSDT unleashed
SSDT unleashed
GomathiNayagam S
 
1 extreme performance - part i
1   extreme performance - part i1   extreme performance - part i
1 extreme performance - part isqlserver.co.il
 
Daniel Ridder ABAP Core Data Services No Pain, No Gain
Daniel Ridder ABAP Core Data Services No Pain, No GainDaniel Ridder ABAP Core Data Services No Pain, No Gain
Daniel Ridder ABAP Core Data Services No Pain, No Gain
Daniel Ridder
 
SQL vs NoSQL deep dive
SQL vs NoSQL deep diveSQL vs NoSQL deep dive
SQL vs NoSQL deep dive
Ahmed Shaaban
 
Cool features 7.4
Cool features 7.4Cool features 7.4
Cool features 7.4
Mahesh Someshetty
 
Build a Big Data solution using DB2 for z/OS
Build a Big Data solution using DB2 for z/OSBuild a Big Data solution using DB2 for z/OS
Build a Big Data solution using DB2 for z/OS
Jane Man
 
Crystal Reports Review
Crystal Reports ReviewCrystal Reports Review
Crystal Reports ReviewJustin R. Rue
 
What's new in microsoft dynamics ax7
What's new in microsoft dynamics ax7What's new in microsoft dynamics ax7
What's new in microsoft dynamics ax7
Sameh Senosi
 
Azure from scratch part 3 By Girish Kalamati
Azure from scratch part 3 By Girish KalamatiAzure from scratch part 3 By Girish Kalamati
Azure from scratch part 3 By Girish Kalamati
Girish Kalamati
 
Modernizing your database with SQL Server 2019
Modernizing your database with SQL Server 2019Modernizing your database with SQL Server 2019
Modernizing your database with SQL Server 2019
Antonios Chatzipavlis
 
Azure DevOps for the Data Professional
Azure DevOps for the Data ProfessionalAzure DevOps for the Data Professional
Azure DevOps for the Data Professional
Sarah Dutkiewicz
 
SQL Server 2019 Big Data Cluster
SQL Server 2019 Big Data ClusterSQL Server 2019 Big Data Cluster
SQL Server 2019 Big Data Cluster
Maximiliano Accotto
 
RDBMS to NoSQL: Practical Advice from Successful Migrations
RDBMS to NoSQL: Practical Advice from Successful MigrationsRDBMS to NoSQL: Practical Advice from Successful Migrations
RDBMS to NoSQL: Practical Advice from Successful Migrations
ScyllaDB
 
Database CI/CD Pipeline
Database CI/CD PipelineDatabase CI/CD Pipeline
Database CI/CD Pipeline
muhammadhashir57
 
Sas hpa-va-bda-exadata-2389280
Sas hpa-va-bda-exadata-2389280Sas hpa-va-bda-exadata-2389280
Sas hpa-va-bda-exadata-2389280
Edgar Alejandro Villegas
 
Azure for SharePoint Developers - Workshop - Part 3: Web Services
Azure for SharePoint Developers - Workshop - Part 3: Web ServicesAzure for SharePoint Developers - Workshop - Part 3: Web Services
Azure for SharePoint Developers - Workshop - Part 3: Web Services
Bob German
 

Similar to CDS Views.pptx (20)

SITIST 2015 Dev - Abap on Hana
SITIST 2015 Dev - Abap on HanaSITIST 2015 Dev - Abap on Hana
SITIST 2015 Dev - Abap on Hana
 
Readme
ReadmeReadme
Readme
 
Sap hana on technical level By Yogesh Gupte
Sap hana on technical level By Yogesh Gupte Sap hana on technical level By Yogesh Gupte
Sap hana on technical level By Yogesh Gupte
 
SSDT unleashed
SSDT unleashedSSDT unleashed
SSDT unleashed
 
1 extreme performance - part i
1   extreme performance - part i1   extreme performance - part i
1 extreme performance - part i
 
Daniel Ridder ABAP Core Data Services No Pain, No Gain
Daniel Ridder ABAP Core Data Services No Pain, No GainDaniel Ridder ABAP Core Data Services No Pain, No Gain
Daniel Ridder ABAP Core Data Services No Pain, No Gain
 
SQL vs NoSQL deep dive
SQL vs NoSQL deep diveSQL vs NoSQL deep dive
SQL vs NoSQL deep dive
 
Cool features 7.4
Cool features 7.4Cool features 7.4
Cool features 7.4
 
Build a Big Data solution using DB2 for z/OS
Build a Big Data solution using DB2 for z/OSBuild a Big Data solution using DB2 for z/OS
Build a Big Data solution using DB2 for z/OS
 
Crystal Reports Review
Crystal Reports ReviewCrystal Reports Review
Crystal Reports Review
 
What's new in microsoft dynamics ax7
What's new in microsoft dynamics ax7What's new in microsoft dynamics ax7
What's new in microsoft dynamics ax7
 
Dashboard
DashboardDashboard
Dashboard
 
Azure from scratch part 3 By Girish Kalamati
Azure from scratch part 3 By Girish KalamatiAzure from scratch part 3 By Girish Kalamati
Azure from scratch part 3 By Girish Kalamati
 
Modernizing your database with SQL Server 2019
Modernizing your database with SQL Server 2019Modernizing your database with SQL Server 2019
Modernizing your database with SQL Server 2019
 
Azure DevOps for the Data Professional
Azure DevOps for the Data ProfessionalAzure DevOps for the Data Professional
Azure DevOps for the Data Professional
 
SQL Server 2019 Big Data Cluster
SQL Server 2019 Big Data ClusterSQL Server 2019 Big Data Cluster
SQL Server 2019 Big Data Cluster
 
RDBMS to NoSQL: Practical Advice from Successful Migrations
RDBMS to NoSQL: Practical Advice from Successful MigrationsRDBMS to NoSQL: Practical Advice from Successful Migrations
RDBMS to NoSQL: Practical Advice from Successful Migrations
 
Database CI/CD Pipeline
Database CI/CD PipelineDatabase CI/CD Pipeline
Database CI/CD Pipeline
 
Sas hpa-va-bda-exadata-2389280
Sas hpa-va-bda-exadata-2389280Sas hpa-va-bda-exadata-2389280
Sas hpa-va-bda-exadata-2389280
 
Azure for SharePoint Developers - Workshop - Part 3: Web Services
Azure for SharePoint Developers - Workshop - Part 3: Web ServicesAzure for SharePoint Developers - Workshop - Part 3: Web Services
Azure for SharePoint Developers - Workshop - Part 3: Web Services
 

Recently uploaded

Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTSHeap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Soumen Santra
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
Massimo Talia
 
Modelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdfModelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdf
camseq
 
原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样
原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样
原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样
obonagu
 
A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...
nooriasukmaningtyas
 
Water billing management system project report.pdf
Water billing management system project report.pdfWater billing management system project report.pdf
Water billing management system project report.pdf
Kamal Acharya
 
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
ydteq
 
Unbalanced Three Phase Systems and circuits.pptx
Unbalanced Three Phase Systems and circuits.pptxUnbalanced Three Phase Systems and circuits.pptx
Unbalanced Three Phase Systems and circuits.pptx
ChristineTorrepenida1
 
14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application
SyedAbiiAzazi1
 
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
insn4465
 
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
awadeshbabu
 
Fundamentals of Induction Motor Drives.pptx
Fundamentals of Induction Motor Drives.pptxFundamentals of Induction Motor Drives.pptx
Fundamentals of Induction Motor Drives.pptx
manasideore6
 
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdfGoverning Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
WENKENLI1
 
ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024
Rahul
 
bank management system in java and mysql report1.pdf
bank management system in java and mysql report1.pdfbank management system in java and mysql report1.pdf
bank management system in java and mysql report1.pdf
Divyam548318
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
thanhdowork
 
basic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdfbasic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdf
NidhalKahouli2
 
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdfBPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
MIGUELANGEL966976
 
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
Mukeshwaran Balu
 
Fundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptxFundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptx
manasideore6
 

Recently uploaded (20)

Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTSHeap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
 
Modelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdfModelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdf
 
原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样
原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样
原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样
 
A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...
 
Water billing management system project report.pdf
Water billing management system project report.pdfWater billing management system project report.pdf
Water billing management system project report.pdf
 
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
 
Unbalanced Three Phase Systems and circuits.pptx
Unbalanced Three Phase Systems and circuits.pptxUnbalanced Three Phase Systems and circuits.pptx
Unbalanced Three Phase Systems and circuits.pptx
 
14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application
 
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
 
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
 
Fundamentals of Induction Motor Drives.pptx
Fundamentals of Induction Motor Drives.pptxFundamentals of Induction Motor Drives.pptx
Fundamentals of Induction Motor Drives.pptx
 
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdfGoverning Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
 
ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024
 
bank management system in java and mysql report1.pdf
bank management system in java and mysql report1.pdfbank management system in java and mysql report1.pdf
bank management system in java and mysql report1.pdf
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
 
basic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdfbasic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdf
 
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdfBPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
 
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
 
Fundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptxFundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptx
 

CDS Views.pptx

  • 1. Core Data Services (CDS) May 19th, 2017
  • 2. Meet The Speaker Jonathan Andre Lead Developer IT Partners
  • 3. Our Agenda About CDS / How to Create Basic ABAP CDS View Other Features ABAP CDS HANA CDS and Native SQL
  • 4. What is CDS? • Core Data Services, or CDS, is a “semantically rich” Data Definition Language (or DDL) created by SAP. It provides an easy to understand and reusable tool that ABAP developers can utilize to execute the “code pushdown” paradigm. • CDS comes in different flavors , a HANA version and an ABAP version: • HANA CDS - The lesser used option for ABAP coders is HANA CDS, the database language that can be used to create tables, views, and structures on the HANA database itself. Views created in HANA can be consumed from the Netweaver AS using Native SQL. • ABAP CDS – This is the CDS flavor that will almost be exclusively used in most SAP business software systems. ABAP CDS is usually the best choice when designing and creating database views that will need to access the HANA database.
  • 5. What is CDS? • ABAP CDS, made available with SAP Netweaver 7.40 SP5, allows coders to achieve the “code-to-data” programming paradigm using a reusable resource that can be used across different programs and projects. • “Code-to-data”, also sometimes referred to as “code-pushdown” is the process of moving data intensive programming logic from the application later down to the database layer. • CDS achieves these primarily through the use of “Views”, however the views in the context of CDS go beyond those classical SE11 since much of the logic previously left to the programming level (i.e. ABAP program logic) can now be outsourced to the database level. • Although CDS performs well with the HANA database and takes advantage of many of its features, it is actually an OPEN DDL (data definition language) language. The term Open meaning that it will work with all traditional databases that can be used to run the latest versions of the SAP NetWeaver products. • An ABAP CDS file can ONLY be create within the Eclipse IDE (there is no transaction to do this from SAP GUI). CDS files are written in an augmented form of SQL Script
  • 6. Creating First CDS View (Using AWS)
  • 7. Creating First CDS View (Using AWS)
  • 8. Creating First CDS View (Using AWS)
  • 9. Creating First CDS View (Using AWS)
  • 10. Creating First CDS View (Using AWS) Opening Annotations – These declare high level data about the CDS view: • @AbapCatalog.sqlViewName is the only mandatory annotation for a non- extending CDS View source file. • @AbapControl.authorizationCheck specifies whether an authorization check should be performed for the current CDS view.
  • 11. Creating First CDS View (Using AWS) Datasource Declarations- This section will come after the opening Annotations, but before the first curly bracket. Within this section, the developer specifies: • the type of view (define or extend view) • the CDS view name (in this case ZJON_CDS_VIEW_EXAMPLE), • the source table or view (SNWD_SO) • Any parameters (more on this later) • Any joins/associations (more on this later)
  • 12. Creating First CDS View (Using AWS) Field Declarations and Specifications • After the first curly bracket comes the desired fields from the table, as well as any fields that are to be computed. • This is the section that a developer will primarily utilize to take advantage of code-pushdown. • The CASE function allows a particular value to be returned based on the value of a table field. • We define the field returned as ‘payment_status’. To the calling program, there’s no difference between this generated field and a regular database field.
  • 13. Creating First CDS View (Using AWS) Select Conditions, Restrictions, and Grouping Declarations The last section of the DDL source file is where you would add any selection restrictions (such as a where clause) in addition to any aggregation instructions (such as GROUP BY). We will be covering both of these options in later examples.
  • 14. Previewing a CDS View • CDS Views can be previewed right within the Eclipse editor. To do this, right-click on the created view, select “Open With” and then select “Data Preview” from the submenu. (Note that in other versions of the ABAP Development Tools, the “Data Preview” option may appear immediately in the menu when you right click.) • Notice that, along with the data we have selected from the snwd_so table, we also have the calculated field payment_status that was created using the CASE function.
  • 15. What happens on the HANA DB? • When you create an ABAP CDS View, a corresponding view is created on the HANA DB matching the CDS view created on the ABAP side. • This view will have the SQL View name that you provided (after the @AbapCatalog.sqlViewName annotation) and will be generated automatically after you create the CDS view. • The corresponding HANA view does not require a separate transport to move between HANA DBs. Once the view is transported and executed on SAP NetWeaver, the HANA View will be generated automatically in the corresponding HANA DB. • You can view the create SQL view in Eclipse by using the SQL HANA Administrator Perspective (described on the next slide).
  • 16. What happens on the HANA DB? 1 – Open the SAP HANA Administrator Console 2 – Log into the HDB system (password should be the same one for all usernames/windows login. 3 – Open the Catalog folder 4 – Navigate to the SAPA4H schema (which holds all tables/views for SAP NetWeaver) 5 – Click find table and type the sqlViewName you used for your first view (or any other CDS view you’ve created). NOTE: Theres no requirement that his SQL View name be the same as your CDS view name! This SQL view name will be in the annotations section.
  • 17. What happens on the HANA DB? Double click on the SQL View name corresponding to your CDS view, and you should see a display with two tabs. The first tab, Columns, displays the columns that are available with your CDS View. The second tab shows the SQL statement for your view, which should look familiar. It should be nearly identical to the CDS View you coded on the NetWeaver side, with a few syntax adjustments to make it compatible with the HANA DB.
  • 18. Using a CDS View in an ABAP Program Using a CDS view simply requires using an Open SQL statement that selects from our CDS Entity (ZJON_CDS_VIEW_EXAMPLE). As an added benefit of ABAP CDS, a generated CDS Entity name can also be used in DATA declarations to create structures of a compatible TYPE:
  • 19. Associations Associations are essentially reusable JOINS that relate two CDS Entities (tables or views) to each other. CDS Associations have the added benefit of being able to specify cardinality ([1..1], [0..1], [*], etc.). Many of the features of ASSOCIATIONS are available as JOINS, however ASSOCIATIONS are the preferred and more elegant option when merging two CDS entities.
  • 20. Aggregate Functions The aggregate functions available in CDS Views are the same ones that are available in the new Open SQL. Although they are readily available during a regular Open SQL Select, it is still an extremely useful tool to have in CDS Views. Using the CDS approach, developers can make certain summary data uniform across projects and systems without having to maintain entirely separate summary level tables. As you can see in the above example, any time you use these aggregate functions in the field declaration section, you are required to include the GROUP BY addition in the Selection Restriction and Condition section. Removing the GROUP BY clause while having either of these functions remaining will raise a syntax error, which is logical since you cannot have summary level data item level records.
  • 21. Aggregate Functions The data preview shows that, instead of showing every single SO in the system, we are now showing the data summarized by company. Using our CDS View with aggregate functions allows your us to view every company with unpaid sales orders with gross amounts over $500, who many of these sales orders they have, and the total gross amount of the sales orders. Before HANA, a calculation like this would require selecting all this data into an internal table, looping through the documents one by one, and keeping track of totals. Using CDS/HANA we can view this data much faster with all the work already completed for us!
  • 22. CDS View Parameters • CDS Views also allow for parameters to be used to help in building more dynamic views. • Parameter can be used to provide variable conditions to search conditions (similar to what one would achieve by using a WHERE clause. • Parameters can also be used to provide values for CASE statements, arithmetic calculations when calculating fields, and performing other alterations to functional operations that would not be possible with a classical SELECT statement. • All CDS Parameters are MANDATORY.
  • 23. Using CDS Views with Parameters • To use the parameters in a SELECT statement, you would need to use parentheses after immediately following the CDS View name. This is similar to how you would pass parameters to a method call. • You can use variable values in the parameters by using the ‘@’ symbol before the variable name (which is common the new Open SQL syntax). • If you prefer to use hard coded strings or values instead, the ‘@’ is not required.
  • 24. Extending Views • Existing CDS Views can also be “enhanced” by creating a separate Extend View that contains additional fields you would like to include. • For instance, in this example we would like to extend our original view ZJON_CDS_VIEW_EXAMPLE. • To do this we create a NEW view ZJON_VIEW_EXAMPLE_PAID_EXTND as shown to the right. • This will EXTEND the original view and add the field “so_status”. • This is useful when trying to modify views original created by SAP with customs fields.
  • 25. Extending Views The original views source code will be modified with a familiar icon, which indicates it has been extended by another view
  • 26. Creating a HANA CDS View (Prerequisite) If you try to create a HANA CDS View with the default settings, you will get a strange encoding error. Update your workspace settings BEFORE creating your HANA CDS View (or you will have to delete it and restart) Follow the menu path: Window->Preferences->General With the general section expanded, click on the Workspaces text. Change your encoding from the default cp1252 to UTF-8 (under other)
  • 27. Creating a HANA CDS View • Click the New Perspective icon in the top right of the window (to the left of the ABAP icon) • Locate the SAP HANA Development perspective and hit OK.
  • 28. Creating a HANA CDS View 2 – Click the “Systems” Tab 3- Double click the HDB system 4 – Enter your password (same as password for everything else) 1- Ensure you are in the SAP HANA Development Perspective(it looks very similar to the ABAP Perspective)
  • 29. Creating a HANA CDS View • While still in the SAP HANA Development Perspective, navigate to the Project Explorer tab (you will still see your ABAP projects listed, which is fine) • Right click in the white space, then navigate to New->Project… • Follow the menu path SAP HANA- >Application Development then click XS Project • Give the project a name (for the source code to work as provided the name must be ZJON_CDS ) • Select the Default workspace • Deselect the to access objects and hit finish.
  • 30. Creating a HANA CDS View • Right click on the new project, the navigate to New->Other • Then navigate to SAP HANA->Database Development-> DDL Source File
  • 31. Creating a HANA CDS View • Enter the desired name of your CDS View (it must be ZJON_CDS for the source code to work) • Select the project that was just created • Hit Finish
  • 32. Creating a HANA CDS View • To the right is an example CDS view. You will notice that it does not have the same annotations as the ABAP CDS view. • Instead, it does have the namespace keyword followed by the project name. • In addition, it has an @Schema notation followed by the schema that will be used (this should match the schema that contains your database tables, in this case SAPA4H. • Lastly, note that the field names MUST BE CAPITALIZED (or the code will no compile, leaving you with a very confusing error message) • While this HANA CDS view is still selected, hit the green arrow to activate this CDS view
  • 33. Creating a HANA CDS View • To utilize a HANA CDS View, a Native SQL call is required. This is because the ABAP Data Dictionary has no knowledge of this view since it was defined outside of the NetWeaver AS. • Native SQL can be extremely finicky, and debugging any issues can be extremely difficult. • Compare this code to the first CDS view in terms of complexity, maintainability, and flexibility. Its clear to see why ABAP CDS is always the better option, unless there is some feature that is only accessible through HANA CDS.