Ansicht
Dokumentation

ABENCDS_GENERAL_SYNTAX_RULES - CDS GENERAL SYNTAX RULES

ABENCDS_GENERAL_SYNTAX_RULES - CDS GENERAL SYNTAX RULES

General Material Data   General Material Data  
This documentation is copyright by SAP AG.
SAP E-Book

- General Syntax Rules

The general syntax rules for the CDS DDL, CDS DCL, and CDS BDL for defining CDS objects in ABAP CDS are as follows:

  • Keywords
  • Keywords must be all uppercase, all lowercase, or in lowercase with an uppercase initial letter. Other mixes of uppercase and lowercase are not allowed.

  • Names
  • Names are not case-sensitive.

  • A name must contain at least 2 characters but no more than 30 characters.

  • A name can consist of letters, numbers, underscores (_), and slashes (/).

  • A name must start with a letter, slash character, or underscore. Underscores are recommended as the naming convention for CDS associations.

  • The separator for names with multiple parts is a period (.). Names with multiple parts can be paths, columns with a prefixed data source, and structured annotations.

  • The following CDS keywords cannot be used as names:

  • Literals
  • In general ABAP CDS, untyped numeric and untyped character literals are available:

An untyped character literal is a character string enclosed in single quotation marks (').
An untyped numeric literal is a series of digits between 0 and 9. It can be directly prefixed by a + or - sign and can contain a decimal point (.) after the first digit.
  • In CDS DDL, typed literals are available for CDS view entities and CDS hierarchies. Typed literals are available for almost all built-in ABAP Dictionary data types. A typed literal is specified by writing an ABAP Dictionary data type with the type namespace abap. as prefix followed by the character-like representation of the value in single quotation marks (').

Example: abap.dats'20200101'
  • Escaping literals in ABAP CDS:

A single quote (') is escaped with a single quote:'...''...'.
A backslash (\) is escaped with a backslash: '...\\...'
Escaping with a backslash is not supported in .
  • Comments
  • Two forward slashes (//) introduce a comment, which continues until the end of the line.

  • Comments within lines or that span multiple lines are enclosed by the characters /* and */.

  • Separators
  • Statements can be closed using a semicolon (;). Sometimes this is mandatory.

  • Protected words
  • Certain keywords are protected and cannot be used as self-defined names. The reserved names that cannot be used are specified in the DDIC database table TRESE.

Notes

  • The closing semicolon after a statement is sometimes optional because one piece of CDS source code can currently only contain a single statement.

Examples

  • SELECT, select, and Select are all valid ways of specifying a keyword. seLect and SeLect, on the other hand, produce syntax errors.
  • MYVIEW, myview, and myView all identify the same operand.
  • 0.5 is a valid numeric literal, but .5 is not.





General Data in Customer Master   Addresses (Business Address Services)  
This documentation is copyright by SAP AG.

Length: 8413 Date: 20240427 Time: 045530     sap01-206 ( 85 ms )