Introduction
This Quick Reference is a collection of new CDS functionality made available in ABAP 7.5x releases. This functionality is summarised in a way that will make sense to those familiar with SAP CDS. Links to the SAP Help are also provided throughout to allow the reader to dive in deeper if desired. The version the functionality was released is also given to aid in determining if it is available in your system.
| S/4HANA | 1511 | 1610 | 1709 | 1809 | 1909 | 2020 | 2021 | 2022 | 2023 |
| ABAP | 7.50 | 7.51 | 7.52 | 7.53 | 7.54 | 7.55 | 7.56 | 7.57 | 7.58 |
Contents
CDS View Entity
[@enity_annot1]
[@entity_annot2]
...
[@view_entity_annot1]
[@view_entity_annot2]
...
[DEFINE] [ROOT] VIEW ENTITY view_entity
[parameter_list]
AS select_statement [;]...
Description
CDS view entities are non DDIC-based views. While they were introduced in 7.50 the old DDIC-based views (DEFINE VIEW ddic_based_view) only became obsolete in 7.56.
EXTEND VIEW ENTITY (7.55)
Makes it possible to add new view fields to existing CDS view entities and CDS projection views by using CDS view entity extensions.
EXTEND VIEW ENTITY cds_view_entity | projection_view
WITH
[association1
association2 ...]
{ select_list_extension }
[GROUP BY field1, field2, ... ]
[EXCEPT | INTERSECT | UNION [ALL] { ... }] [;]
ANNOTATE ENTITY (7.53)
Define CDS metadata extensions(type:DDLX) for any CDS entities with the exception of CDS table functions.
@Metadata.layer: #CORE|#LOCALIZATION|#INDUSTRY|#PARTNER|#CUSTOMER
[@entity_annot1]
[@entity_annot2]
...
ANNOTATE ENTITY cds_entity WITH
[ parameter_list]
{ [element_list] }[;]
UNION (7.56)
Now supported in CDS view entities.
EXCEPT (7.56)
Returns all rows of a SELECT statement that are not part of the result sets of the following SELECT statements.
INTERSECT (7.56)
Returns all distinct rows that are included in all result sets of multiple SELECT statements.
GET_NUMERIC_VALUE (7.56)
Conversion Function. Returns the numeric value of a currency or quantity without its currency or unit key.
key carrid,
key connid,
key fldate,
@Semantics.amount.currencyCode: 'currency'
price,
currency,
@Semantics.amount.currencyCode: 'currency'
paymentsum,
GET_NUMERIC_VALUE( paymentsum ) / GET_NUMERIC_VALUE( price )
as number_of_bookings
CURR_TO_DECFLOAT_AMOUNT (7.56)
Conversion Function. Converts the function argument(must have data type CURR and a currency key ) into a type DECFLOAT34.
key id,
cuky as currency,
@Semantics.amount.currencyCode: 'currency'
curr10_4 as amount,
@Semantics.amount.currencyCode: 'currency'
CURR_TO_DECFLOAT_AMOUNT(curr10_4) as curr_conv
SUBSTRING (7.57)
Function enhanced to accept literals, fields, parameters, expressions, and built-in functions as arguments pos and len.
SUBSTRING(arg, pos, len) Substring arg from the position pos with length len.
LEFT and RIGHT (7.57)
Functions enhanced to accept literals, fields, parameters, expressions, and built-in functions as argument len.
LEFT(arg, len) String of the length len with the len left characters of arg (ignoring the trailing blanks).
RIGHT(arg,len) String of the length len with the len right characters of arg (ignoring the trailing blanks).
Typed Literals (7.56)
Now supported in CDS view entities. Not supported in the ON condition of a CDS association.
{
key id,
abap.char'aaa ' as char_trailing_blanks,
abap.sstring'aaa ' as sstring_trailing_blanks,
abap.string'aaa ' as string_trailing_blanks,
'aaa' as untyped_literal }
where
numc1 = abap.numc'1' and
datn < abap.datn'20200101'
CDS Calculated Quantity (7.56)
A new type that is the result of a calculation using amount and/or quantity fields.
Application Session Variables (7.57)
In form $session.vname
vname | Value when accessed |
bs_instance_id | Instance ID of the current business service instance. The returned value has the data type SSTRING. |
bs_zone_id | Zone ID of the current business service instance. The returned value has the data type SSTRING. |
Input Parameters (7.57)
abap.string now supported.
RUTDDLS_MIGRATION_CANDIDATES (7.56)
Evaluates whether a migration from a CDS DDIC-based view to a CDS view entity is possible.
RUTDDLSV2MIGRATION (7.56)
Migrates CDS DDIC-based views to CDS view entities.
RUT_WHERE_USE_SQLVIEW (7.57)
Lists all repository objects that use CDS-managed DDIC views.
Table Buffering Annotation (7.57).
Defines whether table buffering is allowed for a CDS view entity or not.
@AbapCatalog.entityBuffer.definitionAllowed: true|false
CDS entity buffer (7.57)
The actual buffering type can be defined by a separate ABAP tuning object called a CDS entity buffer with the DDL statement:
DEFINE VIEW ENTITY BUFFER ON cds_view_entity
LAYER CORE
| LOCALIZATION
| INDUSTRY
| PARTNER
| CUSTOMER
TYPE SINGLE
| {GENERIC NUMBER OF KEY ELEMENTS number}
| FULL
| NONE
Table buffering can be defined differently for the layers core, localization, industry, partner and customer.
DISTINCT (7.56)
Available for SELECT statements in CDS view entities. Works like ABAP SELECT.
Reusing Expressions (7.56)
Reuse expressions defined in the SELECT list in other operand positions of the same CDS view entity.
key id as field1,
concat($projection.field1, 'x') as field_reuse,
WHERE clause (7.56)
Now supports arithmetic expressions and case expressions as operands.
define view entity DEMO_SALES_ORDER_WHERE
as select from
demo_sales_order
association to demo_sales_bupa as _partner
on $projection.id = _partner.id
{
key so_key,
id,
company_code,
_partner.family_name
}
where
_partner.family_name like 'S%'
and length( _partner.family_name ) = abap.int1'4'
and created_on between abap.dats'20200101' and abap.dats'20200401'
and cast( _partner.birth_name as DEMO_BT_BIRTH_NAME
preserving type ) = abap.char'Meier'
HAVING clause (7.56)
Now supports arithmetic expressions and case expressions as operands.
define view entity DEMO_CDS_VIEW_ENTITY_HAVING
as select from sflight
{
concat_with_space(carrid, connid, 1) as ID,
count(*) as col_count,
seatsmax
}
group by
carrid,
connid,
seatsmax
having
seatsmax > abap.int2'500'
Searched Case Expression (7.56)
Now supports arithmetic expressions and case expressions as operands.
define view entity demo_cds_searched_case_ve
as select from
spfli
{
key carrid,
key connid,
distance,
distid,
case
when distance >= 2000 then 'long-haul flight'
when distance >= 1000 and
distance < 2000 then 'medium-haul flight'
when distance < 1000 then 'short-haul flight'
else 'error'
end as flight_type
}
where
distid = 'MI'
[@entity_annot1]
[@entity_annot2]
...
[DEFINE] [ROOT] ABSTRACT ENTITY abstract_entity
[parameter_list]
element_list[;]
Works like a structure definition but nothing is created in DDIC and has annotations that can be evaluated with class CL_DD_DDL_ANNOTATION_SERVICE.
EXTEND ABSTRACT ENTITY (7.56)
Allows extension of existing abstract entity
EXTEND ABSTRACT ENTITY cds_abstract_entity WITH { element_list_extension }
To-Parent Association Without ON (7.56)
The ON condition can be left out of a āto-parentā if the association target is also a CDS abstract entity.
define abstract entity DEMO_CDS_ABSTRACT_CHILD
{
key key_field : abap.char(1);
data_field : abap.int4;
_to_parent : association to parent DEMO_CDS_ABSTRACT_COMPOSITION
on _to_parent.key_field = $projection.key_field;
<- Last line can be omitted
}
[@entity_annot1]
[@entity_annot2]
...
[@ObjectModel.query.implementedBy : 'class_name']
[DEFINE] [ROOT] CUSTOM ENTITY custom_entity
[parameter_list]
element_list[;]
No DDIC entries created and has annotations that can be evaluated with class CL_DD_DDL_ANNOTATION_SERVICE.
Used in RAP as basis of unmanaged queries.
EXTEND CUSTOM ENTITY (7.57)
Makes it possible to add new elements to existing CDS custom entities by using CDS custom entity extensions.
EXTEND CUSTOM ENTITY CustomEntity WITH { ElementListExtension }
[@entity_annot1]
[@entity_annot2]
...
[@proj_view_annot1]
[@proj_view_annot2]
...
DEFINE [ROOT] VIEW ENTITY projection_view
[ PROVIDER CONTRACT provider_contract] [From 7.56]
AS PROJECTION ON cds_entity [AS alias_name]
[association1 association2 ...] [From 7.55]
[redefined_assoc1 redefined_assoc2 ...] [From 7.56]
{ projection_list }
[WHERE cds_cond] [From 7.58 for Transactional Interfaces ]
A special CDS view entity that is based on another CDS view entity (called projected entity). CDS projection views adapt a CDS data model for service-specific use cases.
Associations (7.55)
It is possible to add new, local, read-only associations association1, association2 to a projection view. Read-only associations in projection views can only be exposed but they cannot be used in path expressions to expose elements from new associations.
REDEFINE ASSOCIATION (7.56)
For Projection views it is now possible to redefine an association. In this way, it is possible to modify an association from the underlying view.
... REDEFINE ASSOCIATION [source.]_ProjAssoc [ filter] [AS _RedefinedName] redirection ...
PROVIDER CONTRACT (7.56)
For Projection views it is now possible to have a provider contract which specifies the scenario in which a CDS projection view is used. Provider contract options available:
Uses DEFINE [ROOT] VIEW ENTITY AS PROJECTION ON with provider contract āTRANSACTIONAL_QUERYā.
Transactional queries are intended for modelling the projection layer of a RAP business object. A transactional projection view must always be part of a business object. That means it must either be a root entity itself, or it must be part of a composition tree that contains a root entity
Uses DEFINE VIEW ENTITY AS PROJECTION ON with provider contract āTRANSACTIONAL_INTERFACEā.
CDS transactional interfaces serve as stable public interface layer in a CDS data model. They are typically used in the context of the ABAP RESTful Application Programming Model to provide the basis for a RAP BO interface.
WHERE (7.58) condition allowed for Transactional Interfaces.
Uses DEFINE TRANSIENT VIEW ENTITY AS PROJECTION ON with provider contract āANALYTICAL_QUERYā.
A CDS DDL that is intended for modeling analytical queries within a CDS data model. A CDS analytical projection view defines an analytical query in its element_list.
The projected entity cds_entity can be an analytical cube view(7.57) or an analytical dimension view(7.58). One base view can serve as a basis for multiple analytical projection views.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 27 | |
| 24 | |
| 20 | |
| 20 | |
| 14 | |
| 13 | |
| 13 | |
| 12 | |
| 12 | |
| 11 |