Please enable JavaScript.
Coggle requires JavaScript to display documents.
HA400-4 - Code-to-Data with ABAP 7.5 - Coggle Diagram
HA400-4 - Code-to-Data with ABAP 7.5
New Open SQL
ABAP variables escaped with @ symbol
Comma-separated column list
Arithmetic expressions using +, -, *, /, DIV, MOD, ABS, FLOOR, CEIL
Common semantics
String concatenation
SQL CASE, COALESCE
RIGHT OUTER JOIN supported
Use brackets in JOIN expressions
ON conditions extended
No field of the right table required in ON condition
No longer limited to Equi-Joins ; Operators like BETWEEN or GREATER THAN / LESS THAN can be used
Fields of the right table in WHERE clause of LEFT OUTER JOIN
Implicit client handling
Maximum number of tables in JOINs increased (50)
Maximum number of subqueries increased (50)
INTO clause at the end
For consistency with UNION syntax
Additions such as UP TO... ROWS after INTO
Key word FIELDS
Exhange order of field list and FROM clause
FROM clause first results in code-completion friendly syntax
Support for UNION and UNION ALL
Only explicit field lists allowed - no *
INTO clause must be at end
The result of UNION ALL can contain duplicates, whereas UNION implies DISTINCT
Core Data Services (CDS) in ABAP
Data Definition Language (DDL)
Model and retrieve data on a sementic level higher than SQL
Extends native SQL means for increased productivity
Annotations
Enrich CDS data models with additional metadata
Begin with @
Different ABAP specific information
AbapCatalog.sqlViewName
is mandatory : specifies the name of the representation of the DDL source in the ABAP dictionary and the database
Buffering
Client dependency (default : client-dependent) => do not include client fields in the definition of CDS views
Reference information for Amount and Quantity columns
Associations
Activation of DDL source
DDL SQL View in ABAP Dictionary view (AbapCatalog.sqlViewName annotation)
Database view
Query Language (QL)
Consume CDS entities via Open SQL in ABAP
Fully transparent SQL extensions
Data Control Language (DCL)
Define authorizations for CDS views
Modelled and declarative approach
Integrates with classic authorization concepts
INNER JOIN, OUTER JOIN
Calculation expressions, aggregation, grouping
Nested views
To create CDS views
Use ABAP Development Tools
In the ABAP Project tree, select the package to contain the CDS view and choose context menu entry New > Other ABAP Repository Object > Dictionary > DDL Source
Use the DDL statement DEFINE VIEW and SQL-like syntax to define the view
Select list
String and arithmetic expressions
Literals
Operators : +, -, *, /, unary -, CEIL, MOD
String expressions, string concatenation operator &&, built-in functions (LPAD, CONCAT, REPLACE, SUBSTRING)
CAST expression
Length determined at activation time
No nesting of CAST expressions
CASE expression
Can be nested
Alias name is required for the resulting column, except for nested CASE
Special built-in functions
Currency and unit conversion
COALESCE to replace null values in results, CURRENCY CONVERSION, UNIT CONVERSION
Alias required for result columns
WHERE clause supported
JOINS supported
INNER, LEFT OUTER, RIGHT OUTER
Before or after the field list
No SELECT * together with joins
Aggregations, Grouping, Filtering supported
All columns not aggregated must be listed in GROUP BY
HAVING clause filters resulting groups, aggregate functions supported
Unions
Column lists of the queries must :
have equal number of columns
be of compatible types in matching order
UNION implies a distinct semantic (the combined result contains no duplicate rows)
UNION ALL does not include distinct (duplicate rows are not removed)
Enhancements
Table column
Arithmetic & CASE expressions
Literals
Not supported when using
Grouping (GROUP BY clause)
UNION (ALL) statements
How to do?
Create a new DDL source using the ABAP Development Tools and use the "extend view <existing CDS view> with <name of the CDS entity>" syntax
Add annotation
AbapCatalog.sqlViewAppendName
Associations in Core Data Services
A COMPLETER (218 à 229)
Core Data Services with Input Parameters
WITH PARAMETERS( )... syntax
Comma-separated list of scalar input parameters with type
Parameter types : predefined or data element
Parameter can be used in
Projection list as element or in expressions
ON conditions of JOINs
Expressions in WHERE or HAVING clauses
Filter expressions
Can be referenced using the syntax $parameter.<parameter name> or :<parameter name>
Annotation can bind input parameter to system field
System field values becomes default value at runtime
Supported for system fields SY-LANGU, SY-UNAME, SY-MANDT, SY-DATUM, SY-UZEIT
Consume CDS view with input parameters in other CDS view
Consume CDS view with input parameter in Open SQL
Provide input parameter(s) (mandatory)
Input parameters bound to system fields can be omitted
Check if feature is supported (cl_abap_dbfeatures=>use_features)
Incorporating Authorization Checks with CDS
Data Control Language (DCL)
Annotations
In DCL Sources
EnduSERtEXT;LABEL
MappingRole
In DDL Sources
AccessControl.authorizationCheck
Access controls versus classic authorization checks
Use classic authorization checks when the application is started
Use CDS access controls for instance-based authorization checks
Access controls on direct CDS view access
Considered when explicitly using the CDS view in a Open SQL statement or SADL
Ignored when queried indirectly via other CDS views
Code-to-Data Approach with ABAP 7.4
Transparent optimizations
Fast Data Access
Optimized SELECT FOR ALL ENTRIES
Table buffer enhancements
New SQL parser
Database-oriented programming model
Better SQL-92 standard support in Open SQL
Core Data Services (CDS Views)
SAP HANA specific features
ABAP Managed Database Procedures (AMDP)
Top-down approach : the ABAP stack manages all entities and deploys all artefacts from the ABAP layer into the database
Classic Open SQL
ADBC and Native SQL can be used to get around the limitations of classic Open SQL
Only DB abstraction layer that defines a common semantic for all SAP supported databases
Enhanced Open SQL versus CDS Views
Use Open SQL if you
Need query in one piece of code only
Need features only available in Open SQL, such as FOR ALL ENTRIES
Use CDS views if you
Have a real re-use case - similar as for Dictionary views