Get Example source ABAP code based on a different SAP table
• 1: ABAP_CDS_PATH_EXPR • *: ABAP_CDS_PATH_EXPR • EXACT ONE TO EXACT ONE ABAP_CDS_PATH_EXPR • EXACT ONE TO ONE ABAP_CDS_PATH_EXPR • EXACT ONE TO MANY ABAP_CDS_PATH_EXPR • ONE TO EXACT ONE ABAP_CDS_PATH_EXPR • ONE TO ONE ABAP_CDS_PATH_EXPR • ONE TO MANY ABAP_CDS_PATH_EXPR • MANY TO EXACT ONE ABAP_CDS_PATH_EXPR • MANY TO ONE ABAP_CDS_PATH_EXPR • MANY TO MANY ABAP_CDS_PATH_EXPR
Cardinality Syntax Written in Words ...$[ ${${EXACT ONE$} $| MANY $| ONE$} $] TO ${${EXACT ONE$} $|MANY $| ONE $}: >
Numeric Syntax ... 1$|*: ...>
What does it do? Specifies the cardinality> of the current CDS association as unique or non-unique. The cardinality can be specified in words or in numbers. The syntax written in words is recommended. The syntax written in words can specify the source> and target cardinalities>. However, it is also possible to specify only the target cardinality. The source cardinality can be omitted. The following combinations are possible:
EXACT ONE TO EXACT ONE>
EXACT ONE TO MANY>
EXACT ONE TO ONE>
MANY TO EXACT ONE>
MANY TO MANY>
MANY TO ONE>
ONE TO EXACT ONE>
ONE TO MANY>
ONE TO ONE>
TO ONE>
TO EXACT ONE>
TO MANY> The numeric syntax only specifies the target cardinality. The target cardinality can be specified either as 1> (to-one), or as *> (to-many). The source cardinality is implicitly set to MANY >. A colon (:>) must be placed at the end of the cardinality specification. If the target cardinality is specified as to-one (using the syntax additions TO EXACT ONE:>, TO ONE:>, or 1:>), it is possible to use filter conditions in path expressions, which are used in WHERE>> clauses or HAVING>> clauses. In a clause like this, it overwrites the cardinality> of the CDS association>. The cardinality cannot be specified as the only addition in square brackets. It must always be combined with a filter condition>.
Latest notes: Specifying the cardinality as to-one cardinality prevents a syntax error if a path specified with filter conditions or with a non-unique cardinality is used in a WHERE>> clause or HAVING>> clause. However, at runtime, there is no check to validate whether the condition achieves the required unique cardinality. NON_V5_HINTS ABAP_HINT_END
ABAP_EXAMPLE_VX5 The following CDS view entity filters the association _Text> using the cardinality specification written in words. DDLS DEMO_CDS_PATH_EXP The class CL_DEMO_CDS_PATH_EXPRESSION>> first enters data into the database tables using INSERT>, and then selects data from the CDS view entity DEMO_CDS_PATH_EXP> using a SELECT> statement. Due to the path expression with filter condition, the result set consists of three rows. Without filter condition, the result set would contain more rows. ABAP_EXAMPLE_END