ABAP Core Data Services (CDS) Cheat - Sheet
ABAP Core Data Services (CDS) Cheat - Sheet
Public
CDS objects
Overview of available CDS objects delivered with ABAP Platform 2023.
CDS entity buffer define view entity Buffer settings for CDS
buffer on entities.
CDS entities
Overview of available CDS entities delivered with ABAP Platform 2023.
© 2024 SAP SE or an SAP affiliate company. All rights reserved. See Legal Notice on www.sap.com/legal-notice for use terms, disclaimers, disclosures, or restrictions related to this material. 2/5
*obsolete. Use a view entity instead.
Annotations
Annotations are used to enhance the source code with meta information. There are ABAP annotations that
are evaluated by the ABAP runtime, and framework-specific annotations that are evaluated by specific
software components. Here are some examples:
@AbapCatalog @Analytics
@EndUserText @Consumption
@Semantics @UI
The complete list with over 1000 annotations and their documentation can be found in the ABAP Keyword
Documentation ABAP CDS - SAP Annotation Documentation. In ADT, the annotation documentation is
available under F2.
Conversions between data types are done with the cast operator:
CAST( <operand> AS <dtype> [PRESERVING TYPE] )
Associations
Associations can be used to define relationships between CDS entities. They are instantiated as a join
expression as soon as a field from the association target is included in the current entity (“join-on-demand”).
Types of associations:
• Association
• To-parent association
• To-child association
Syntax:
association [cardinality] [to] <assoc_target> as <_assoc> on <condition>
The names of associations start with an underscore (_).
To expose a CDS association for reuse, write its name in the select list (_assoc). No join is generated in this
case.
To include a field from an association source in the select list, use a path expression, i.e. a concatenation of
exposed associations. This automatically generates a join expression in the SQL CREATE statement. Example:
_assoc1._assoc2.field_name.
© 2024 SAP SE or an SAP affiliate company. All rights reserved. See Legal Notice on www.sap.com/legal-notice for use terms, disclaimers, disclosures, or restrictions related to this material. 3/5
Session variables
Session variables access current system information in ABAP CDS, similar to sy-fields in ABAP.
Syntax: $session.<variable_name>
The expressions can be nested within each other. For example, a parameter can be used as an operand of a
case expression.
© 2024 SAP SE or an SAP affiliate company. All rights reserved. See Legal Notice on www.sap.com/legal-notice for use terms, disclaimers, disclosures, or restrictions related to this material. 4/5
Syntax overview CDS view entities
DEFINE [ROOT] VIEW ENTITY entity_name
[WITH PARAMETERS …]
AS SELECT FROM data_source
[joins]
[associations]
{
...
}
[WHERE]
[GROUP BY]
[HAVING]
[UNION]
[EXCEPT]
[INTERSECT]
www.sap.com
© 2024 SAP SE or an SAP affiliate company. All rights reserved. See Legal Notice on www.sap.com/legal-notice for use terms, disclaimers, disclosures, or restrictions related to this material. 5/5