CDS Abap 2016
CDS Abap 2016
June 2016
Kranthi Kumar Devangam
We need your help to contribute to our HANA and Big Data Forums
June 2016
4. Annotations
7. Extensibility
8. Authorization Concept
9. Associations
Big Data
Predictive takes advantage And changed the way of
Analysis
of the latest technology developing and executing
… developments
Data-To-Code:
Intensive
computations <code
>
in APPLICATION
layer
Code-To-Data:
Intensive
computations
in DATABASE
layer
Classic Data-Centric
Applications Applications
UI Rendering UI Tier UI & Client Side
Application
UI Application Logic Logic
Data-Centric Logic
SAP HANA
Database
Database Relational
Database
Applications
Core Edge
?
• Same Semantic on all DBs • HANA only (HANA specific
• Initial Focus on View building features available)
A CDS is defined for existing database tables and any other views or CDS views in
ABAP Dictionary using the statement DEFINE VIEW in the DDL in ABAP Core Data
Services (CDS).
§ 2. A CDS entity
Activation
Kernel
CDS DDL
Parser
CREATE/DROP/ALTER VIEW/TABLE …
SQL DDL
Compiler
Annotations are marked with the @ sign on top of DDL Source code in the view.
Core Annotations :
• Are checked by ABAP Dictionary during activation and
saved into ‘Core Metadata’
Generic annotations:
• Are introduced by application user.
• Are evaluated by frameworks of other software components like
ODATA, UI and Analytics
Core
case
when inv_head.node_key is null
then 'Not yet invoiced'
else 'Invoice sent'
end as invoice_info
Example:
define view agg_faglfelxa as select from faglfelxa
{
rclnt, ryear, drcrk,
cast(ceil(poper*0,0625)*16 as abap.numc(3)) as repmax, …
}
The Open SQL SELECT Statement is used in ABAP to fetch data from a CDS View.
Classical views delivered by SAP or partners can be extended with the well known
classical append views. In order to achieve the same for CDS views a new DDL
statement is introduced: EXTEND_VIEW
@AbapCatalog.sqlViewAppendName: 'DEMO_CDS_EXTENS'
{ spfli.distance,
spfli.distid as unit };
It adds new fields to the existing view fields. Technically, a classical append view - its
name defined behind the annotation @AbapCatalog.sqlViewAppendName - is
generated in the ABAP Dictionary for that purpose.
ABAP CDS has its own authorization concept based on a data control language
(DCL).
CDS roles
A CDS role is defined in separate CDS source code for a CDS entity using the DCL
statement DEFINE ROLE.
The following is checked when the CDS entity is accessed using Open SQL:
The Concept
The idea behind the associations in the ABAP Core Data Services (CDS ) is
to provide an adequate representation of a relationship between two entities
in the data model in the ABAP Data Dictionary. If you think of the classical
Entity-Relationship Model as a directed attributed graph, the associations
are the edges of this graph.
The Idea
The idea is to express these relationships as part of the data model, say,
capture them in the meta data stored behind the scenes and make them
available for reuse.
Reusing associations includes an integration into the SQL-like query
language as well as the availability of the association meta data to
frameworks build on top of the ABAP Data Dictionary
Scope:
Ÿ Allow to define „unmanaged“ Associations within CDS-Views and to expose them via the projection
list (for consumption in „View on View“-scenarios)
Ÿ Usage of Associations in SELECT-, FROM-, WHERE- and HAVING-clauses
overview
• In the Where-condition:
where _ScheduleLine.Quantity < 10
Only include items, if their schedule line is less
then 10
Technically, each path step corresponds to a join operation
(see following section: Behind the scenes: Joins )
Path-Expression in CDS
can be used at almost any
place, where a common
column or table could by
used:
• From
• Select-List
• Inside Aggregate
Functions
• Group By
• Where- or Having-
Condition
Path-Expression cannot
be used inside the ON-
clauses of joins or new
association definitions
Advantages
Compared to explicit Joins, path-expressions
have some advantages:
• Relationship is part of the Meta-Data and thus
can be evaluated by Frameworks on top of
CDS
• More Intuitive Query Statements
• Reuse of Meta-Data: the On-Condition is
defined only once
But from a pure technically point of view, path
expressions do not add any additional
functionality to join operations.
OpenSQL
ABAP/DDIC
Table functions as
Plain CDS- Breakout
native HANA
View CDS-View
SQLScript
generates generates
HANA SQL
Example:
• They can be consumed by Open SQL and ABAP CDS like other DDIC artifacts (i.e.
DB tables, classical DDIC views, CDS views ...)
• DDL source can be activated before the implementing AMDP method exists
The usage of ABAP CDS views following the VDM guidelines is mandatory for the
following use cases:
• Any analytical content (e.g. queries, cubes etc. exposed via generic analytical tools like
Lumira, Design Studio)
SELECT * FROM COSP WHERE LEDRR = ’001’ AND OBJNR = ’OR000110708300’ AND
ABAP WRTTP = ’04’ AND BEKNZ IN (’H’ , ’S’ , ’L’ )
HANA
• The new concept of one semantic layer for search, operational and analytical
processing using open CDS views optimized for SAP HANA technology and
infrastructure, allows real-time operational reporting and will be rolled out in all
deployments of S/4HANA, cloud and on premise
• Instead of HANA calculation views, S/4HANA Analytics uses Core Data Services (CDS)
to define views that are still created in the HANA database but defined and accessed
through the ABAP layer. This change allows for a unified set of security roles for
transaction processing and analytics.
• New simplified data models in SAP S/4HANA allow us to streamline the VDM’s and in
order to support ABAP-related use-cases like S/4HANA security and SAP Hierarchies
we have build new Virtual Data Models based on SAP Core Data Services (CDS).
http://wiki.scn.sap.com/wiki/display/ABAP/CDS+-+Core+Data+Services
http://scn.sap.com/docs/DOC-47994#jive_content_id_ABAP_Core_Data_Services_CDS
http://scn.sap.com/community/abap/blog/2015/02/02/core-data-services-cds-abap-feature-
matrix
2. Currency Conversion
3. Use case scenarios done using AMBD can be tried using ABAP CDS.
7. Extensibility
8. Authorization