DEV211 - Core Data Services: Next On Sap Hana: Generation Data Definition and Access
DEV211 - Core Data Services: Next On Sap Hana: Generation Data Definition and Access
DEV211 - Core Data Services: Next On Sap Hana: Generation Data Definition and Access
Public
Disclaimer
The information in this presentation is confidential and proprietary to SAP and may not be disclosed without the permission of
SAP. Except for your obligation to protect confidential information, this presentation is not subject to your license agreement or
any other service or subscription agreement with SAP. SAP has no obligation to pursue any course of business outlined in this
presentation or any related document, or to develop or release any functionality mentioned therein.
This presentation, or any related document and SAP's strategy and possible future developments, products and or platforms
directions and functionality are all subject to change and may be changed by SAP at any time for any reason without notice.
The information in this presentation is not a commitment, promise or legal obligation to deliver any material, code or functionality.
This presentation is provided without a warranty of any kind, either express or implied, including but not limited to, the implied
warranties of merchantability, fitness for a particular purpose, or non-infringement. This presentation is for informational
purposes and may not be incorporated into a contract. SAP assumes no responsibility for errors or omissions in this
presentation, except if such damages were caused by SAPs intentional or gross negligence.
All forward-looking statements are subject to various risks and uncertainties that could cause actual results to differ materially
from expectations. Readers are cautioned not to place undue reliance on these forward-looking statements, which speak only
as of their dates, and they should not be relied upon in making purchasing decisions.
Public
Speakers
Las Vegas, Sept 19 - 23
Bangalore, October 5 - 7
Barcelona, Nov 8 - 10
Christian Stork
Raghuvira Bhagavan
Christian Stork
Andreas Grnhagen
Andreas Grnhagen
Public
Agenda
Introduction
CDS Views and modern Open SQL in detail
Associations
Extending views
Annotations
i
2016 SAP SE or an SAP affiliate company. All rights reserved.
DEV267
Public
Agenda
Introduction
CDS Views and modern Open SQL in detail
Associations
Extending views
Annotations
Public
Semantic gap
SQL:
Public
Code: SELECT
* FROM Employee INTO TABLE it_empl WHERE orgunit = 4711. I know 4711 is the
LOOP AT it_empl.
id of the dev unit
WRITE it_empl-id.
WRITE it_empl-name.
SELECT * FROM Addresse INTO TABLE it_addrs WHERE id = it_empl-id.
LOOP AT it_addrs.
IF it_addrs-type = HOMEADDR.
WRITE it_addrs-zipcode.
ENDIF.
ENDLOOP.
ENDLOOP.
Public
CDS:
Public
Next generation data definition and access for database centric applications
ABAP
CORE DATA SERVICES
</>
Common data model
Semantically rich
Reduced complexity
Declarative
Extending SQL
Public
ABAP CDS
SAP Business Suite EHP7 (Suite on HANA)
HANA CDS
SAP HANA SPS6
Public
10
DDL
QL
DCL
Query Language
Define authorizations
Public
11
[1]
12.239
22.847
724.656
CDS Views
Associations
Lines of Code
in CDS
Views
on 2016-04-26
Public
12
ABAP integration
SAP NetWeaver ABAP
OPEN SQL
CDS ABAP
Lifecycle Management
Public
13
01
Eclipse based
Part of ABAP
Development tools
02
Development tools
Code completion
03
Supportability
Enhanced data preview
Element info
Dependency analyser
Quick-Fix function
Activation graph
Syntax highlighting
Public
14
Demo
Public
15
Agenda
Introduction
CDS Views and modern Open SQL in detail
Associations
Extending views
Annotations
Public
16
CDSin
Build
Views
SQLand
Open
SQL
functions
Use natively
implemented SAP
HANA-DB functions
CDS
CDS Table
Table
Functions
Functions
Public
17
What is selected?
What is name? Column or ABAP variable?
leads to
Public
18
Inner Join
Public
19
UNION ALL
UNION ( DISTINCT )
Public
20
@AbapCatalog.sqlViewName: 'sepmraovwlastsld'
define view SEPMRA_C_OVW_LastSaleDate
as select from
SEPMRA_I_Product_E
as Product {
key Product.Product,
-- enforce the default placeholder image as initial value for property ProductPictureURL:
case Product.ProductPictureURL when '' then '/sap/public/bc/NWDEMO_MODEL/IMAGES/no_photo.jpg'
else Product.ProductPictureURL end
as ProductPictureURL
}
where
LastSaleDate.LastSoldDateTime is null -- not sold at all
or LastSaleDate.LastSoldDateTime < CurrentDateTime.FourWeeksAgoDateTime
Public
21
Public
22
with parameters
p_keyDate: abap.dats
Public
23
@AbapCatalog.sqlViewName:'DEV211_V_PARAMS'
define view DEV211_E_PARAMS
with parameters @Environment.systemField: #SYSTEM_DATE p_keyDate: abap.dats
as select from SEPMRA_I_OrgAsgmntForKeyDate( p_keyDate : $parameters.p_keyDate )
{ * }
Public
24
Generic
Date / Time
Build in
SQL
functions
Arithmetic
Conversion
String
Public
25
Arithmetic
Concat
Abs
Instr
Ceil
Left / right
Div (integer)
Length
Division (dec)
Generic
Floor
Simple- /
Mod
searched-case
Round
Coalesce
Conversion
Date / Time
Ltrim / rtrim
Days between
Replace
Add days
Unit conversion
Add month
Currency conversion
Current tmstp
Cast
Lpad / rpad
Date is valid
Hex2Bin
Tmstp is valid
Bin2Hex
Decimal shift
Add seconds
Public
26
Demo
Public
27
Agenda
Introduction
CDS Views and modern Open SQL in detail
Associations
Extending views
Annotations
Public
28
SQL Joins as Means for Combining Fields from Two or More Tables
define view zddl_join
as select from SEPM_I_SalesOrderItem as I
Not reusable
Do not contribute to the data model
Public
29
_Currency
}
Public
30
Projection
List
Having
Clause
Group by
Clause
Left
Outer
Join
From Clause
Inner
Join
Public
31
Filter Expressions
define view zddl_bpa
as select from SEPM_I_BusinessPartner
{
_Address[1: Country = 'DE' ].CityName
}
Public
32
FIELDS \_Address-PostalCode
INTO @DATA(result).
Public
33
Demo
Public
34
Agenda
Introduction
CDS Views and modern Open SQL in detail
Associations
Extending views
Annotations
Public
35
Consumer
Consumer
Consumer
C2
C1
View on View
C3
View on View
V1
Extensions
V2
&
Hierarchical view-on-view
concept
Optimized result-sets with
minimum data transfer
Append additional columns,
arithmetic expressions or
literals to result set
Basic View
B1
Public
36
View extends
Extending view Business Partner
{
_Address.cityname
}
Public
37
Demo
Public
38
Agenda
Introduction
CDS Views and modern Open SQL in detail
Associations
Extending views
Annotations
Public
39
CDS ANNOTATIONS
Business
Logic
OData
Analytics
BI-Tools
Planning
Search
Public
40
Annotations example
@AbapCatalog.sqlViewName : ZDDL_ANNOTATIONS
@EndUserText.label: 'Business Partner with street'
@AccessControl.authorizationCheck: #NOT_REQUIRED
define view zddl_bpa
as select from SEPM_I_BusinessPartner
{
@Semantics.address.street: true
_Address[1 : Country = 'DE' ].StreetName
}
Public
41
Annotation allows
independency from Core Data Model
And can be defined at many view
parts!
Public
42
Agenda
Introduction
CDS Views and modern Open SQL in detail
Associations
Extending views
Annotations
Public
43
SQL string
Logical Plan
Rewriting
Parsing
Result
select *
from T1,T2,T3,T4
where T1.A=T2.A
and T2.B=T3.B
and T3.C=T4.C
and T1.A = 100
select clause
J3
J3
J2
J5
J8
T1
J4
T2
T3
T1
T2
T1
T4
T3
J6
T4
J3
J10
T2
J1
Runtime
Compilation
J2
J1
J1
Execution
Plan
J9
from clause
Get an Insights
T3
T4
Execution Plan
= Cached Plan
= Physical Plan
J7
Cost-based
Best Plan
Selection
J2
where clause
Physical
Algorithm
Enumeration
Logical Plan
Enumeration
Visualize
via XML
Disable/enable/
visualize
rewrite rules
(what-if analysis)
Visualize
via XML
Change to alternative
plans and execute
(what-if analysis)
(hot-spot
analysis)
HANA PlanViz
2016 SAP SE or an SAP affiliate company. All rights reserved.
Public
44
Performance
CDS Views && Open SQL are Code
Pushdown to the Database:
Performance strongly depends on the
database optimizer
Small changes can lead to
significantly different execution plans
on the database
Public
45
Demo
Public
46
Agenda
Introduction
CDS Views and modern Open SQL in detail
Associations
Extending views
Annotations
Public
47
BREAKOUT SCENARIOS
Database specific
Currently SAP HANA DB only
No automatic fallback
for Any-DB
Public
48
Parameter list
Return Parameter
Reference to implementing method
DDL
Source
ABAP
Managed
Database
Procedure
SAP HANA
Database
AMDP Implementation
Includes SQL-script
function body
Public
49
Link to implementation
Public
50
Marker interface
Method name and link to CDS view
for signature inheritance
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.
Public
51
Implementation in special
tagged method
Table functions are read-only
Used ABAP managed objects
Implementation in SQLScript
Public
52
Public
53
Agenda
Introduction
CDS Views and modern Open SQL in detail
Associations
Extending views
Annotations
Public
54
CDS
View
</>
DCL
SQL
</>
Public
55
DCL approach
Classical approach
PFCG
PFCG
<Code>
<Code>
DCL
SQL
Authorization
Check
<Code>
&
SQL
CDS
View
<Code>
Public
56
Scenario
@AbapCatalog.sqlViewName : SALESORDERS_V
@AccessControl.authorizationCheck: #CHECK
define view SalesOrders as select from SalesOrder_Table
{
key SalesOrder as SalesOrderNumber,
CDS-View ( to be authorized )
GrossAmount,
SalesOrg, // This is the field which is relevant for the authority check
_Items,
_Buyer
}
Public
57
Rating
No reuse
Every access to the view has to be secured separately
Public
58
role DCL_SalesOrders {
grant select on SalesOrders
where (SalesOrg) = aspect pfcg_auth(S_SALES,
ORGUNIT, actvt = '03');
}
SELECT * FROM SalesOrders
INTO CORRESPONDING FIELDS OF TABLE @lt_SalesOrders.
Rating
Public
59
SQL Translation
Retrieved from the user context
role DCL_SalesOrders {
grant select on SalesOrders
where (SalesOrg) = aspect pfcg_auth(S_SALES,
ORGUNIT, actvt = '03');
}
SELECT * FROM SalesOrders
INTO CORRESPONDING FIELDS OF TABLE @lt_SalesOrders.
Public
60
1
2
3
4
5
6
Extensible
Public
61
Questions &&
Answers
Public
Demo Jam
SAP TechEd live interviews
Select lecture sessions
Hands-on sessions
Public
63
Further information
Related SAP TechEd sessions:
DEV267 - Building Applications with ABAP Using Code Pushdown to the Database
DEV109 - The ABAP Programming Model in SAP S/4HANA
DEV212, DEV268 - Building an End-to-End SAP Fiori App Based on SAP S/4HANA and ABAP
DEV265 - ABAP Today
DEV266 - Code Better with ABAP in Eclipse
Public
64
Feedback
Please complete your
session evaluation for
DEV211
Public
65
Some pictures used in this presentation have been made available on the web page www.pexels.com under a Creative Commons Zero (CC0) license,
https://creativecommons.org/publicdomain/zero/1.0/
Public
66