SAP CDS F1 CUSTOM ASSOCIATION



Get Example source ABAP code based on a different SAP table
  


• ASSOCIATION ABAP_CDS_DEFINE_CUSTOM
• TO ABAP_CDS_DEFINE_CUSTOM
• ON ABAP_CDS_DEFINE_CUSTOM

ABAP_CDS_DDL - DEFINE CUSTOM ENTITY, association

ABAP_SYNTAX
... ASSOCIATION $[cardinality$] TO target ON cds_cond
$[ WITH DEFAULT FILTER cds_cond $] ...

ABAP Addition
1 ... cardinality
2 ... ON cds_cond
3 ... WITH DEFAULT FILTER cds_cond

What does it do?
Defines a CDS association in the element list of a CDS custom entity. The CDS association uses an ON condition to associate the current CDS entity with the association target target. The association target can be a CDS view entity, a CDS table function, a CDS hierarchy, another CDS custom entity, a CDS abstract entity, a ABAP_CDS_V1_VIEW , a DDIC database table, or a DDIC database view.
The syntax is similar to the syntax of the addition ASSOCIATION in the SELECT statement of a CDS view entity with the following differences:
The addition AS _assoc is not used. The CDS association is declared using the name _assoc in the element list of the CDS custom entity, after which the addition ASSOCIATION is specified in the element list.
There are further restrictions regarding the syntax of the ON condition (see below).
A CDS association defined using the addition ASSOCIATION in the element list of a CDS custom entity is always exposed. It cannot, however, be used in any SQL path expressions, either in ABAP CDS or in AB_SQL .



Latest notes:

A CDS association of a CDS custom entity cannot be used anywhere where it could produce instances of join expressions.
For an overview of all possible association targets of all CDS entities that can define associations, see Data Source Matrix.
NON_V5_HINTS
ABAP_HINT_END

ABAP_EXAMPLE_VX5
The following DDL source code shows a CDS custom entity that exposes a CDS association with another CDS custom entity:
DDLS DEMO_CDS_CUSTOM_SO
ABAP_EXAMPLE_END

ABAP Addition

What does it do?
The same rules apply as described in topic CDS DDL - CDS View Entity, cardinality .

ABAP Addition

What does it do?
When specifying the ON condition, the following rules apply:
Fields of the association source must be prefixed by the name of the data source.
The fields of the association target must be prefixed by the name of the CDS association (prefix _assoc. separated by a period).
Fields that are listed in the SELECT list of the current view entity must be prefixed with $projection.
The following rules apply to the operands and syntax of the ON condition:
As relational operators, comparison operators are allowed as well as BETWEEN , LIKE, IS NULL, IS INITIAL.
The Boolean operators NOT, AND and OR are allowed.
lhs can be a field of one of the two data sources data_source of the CDS association. If a comparison operator is used as operator, then lhs can also be an untyped literal. ABAP_NOTE Typed literals are currently not supported at this position.
rhs can be a field of both data sources data_source of the CDS association, an untyped literal, or a session variable. ABAP_EXCEPTION if the operator LIKE is used, then rhs must be an untyped character literal.
Path expressions are not allowed.
CDS DDL expressions are not allowed.
ABAP_NOTE Stricter rules exist for CDS custom entities that are used as queries in the context of the ABAP RESTful Application Programming Model. See the development guide for the ABAP RESTful Application Programming Model, section Query.
• WITH DEFAULT FILTER ABAP_CDS_DEFINE_CUSTOM

ABAP Addition

What does it do?
The same rules apply as described in topic CDS DDL - CDS View Entity, ASSOCIATION.