0% found this document useful (0 votes)
303 views5 pages

ABAP Core Data Services (CDS) Cheat - Sheet

aBAP Clean Core

Uploaded by

Yuwono Andre
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
303 views5 pages

ABAP Core Data Services (CDS) Cheat - Sheet

aBAP Clean Core

Uploaded by

Yuwono Andre
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

PUBLIC

ABAP Core Data Services (CDS) Cheat Sheet

Public
CDS objects
Overview of available CDS objects delivered with ABAP Platform 2023.

CDS object Syntax Use

CDS entity Data modeling.

CDS entity extension extend view entity Extending CDS entities.

CDS metadata annotate entity Adding annotations to a


extension CDS object in a separate
repository object.

CDS annotation define annotation Adding semantic


definition information to CDS
objects.

CDS entity buffer define view entity Buffer settings for CDS
buffer on entities.

CDS type define type <name> User-defined data type.


[enum]

CDS scalar function define scalar User-defined function,


function implemented in AMDP.

CDS access control define role on Authorization control.

CDS entities
Overview of available CDS entities delivered with ABAP Platform 2023.

CDS entity Syntax Use

View entity define view entity Data selection.

Projection view define view entity Fine-tuning a data


… as projection on model for a service-
specific use case.

Table function define table Data selection using


function AMDP.

Hierarchy define hierarchy Wrapping of HANA-


native hierarchy
functions.

Custom entity define custom Data selection using an


entity ABAP class.

Abstract entity define abstract Modeling a structure.


entity

DDIC-based view* define view Data selection.

© 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:

ABAP annotation Framework-specific


annotation

@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.

Data types and type conversions in ABAP CDS


• Built-in CDS types are written with the prefix abap., for example, abap.int4.

• Simple types and enumerated types are user-defined CDS types.

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 following variables <variable_name> are available:


Name Explanation

user The logged on ABAP


user, same as sy-uname.

client The current session


client, same as sy-
mandt.

system_language The logon language,


same as sy-langu.

system_date Current system date,


same as sy-datum.

user_timezone Time zone of the user,


same as sy-zonlo.

user_date Current date of the user,


same as sy-datlo.

ABAP Keyword Documentation

Expressions in the select list


The following operands and expressions are available in the select list of a view entity:
• CDS source fields
• Literals (typed or untyped)
• Session variables
• Input parameters
• Arithmetic expressions +, -, *, /
• Aggregate expressions max, min, avg, sum, count, count(*)
• Case expressions – simple and complex
• Path expressions
• Built-in functions

The expressions can be nested within each other. For example, a parameter can be used as an operand of a
case expression.

Operands and Expressions (ABAP Keyword Documentation)

© 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]

DEFINE VIEW ENTITY, ABAP Keyword Documentation

Knowledge Resources for ABAP CDS


• ABAP Data Models | SAP Help Portal
• ABAP Core Data Services in the ABAP Keyword Documentation (sap.com)
• ABAP CDS Development Tools: User Guide | SAP Help Portal
• ABAP CDS Feature Tables
• ABAP CDS Glossary
• Getting Started with ABAP Core Data Services (CDS) - SAP Community

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

You might also like