SAP CDS TABLE FUNCTIONS



Get Example source ABAP code based on a different SAP table
  


VERSION 5 IN

ABAP_CDS - Table Functions
A CDS table function is defined in the DDL source code of a CDS data definition in the ABAP Development Tools using the statement DEFINE TABLE FUNCTION in the CDS DDL of the ABAP Core Data Services (CDS).
BEGIN_SECTION VERSION 5 OUT DCL source code in a CDS table function can also be displayed in Repository Browser in ABAP Workbench.
END_SECTION VERSION 5 OUT A CDS table function includes the following:
The CDS entity A CDS table function is declared as a CDS entity table_function using the statement DEFINE TABLE_FUNCTION. As a global data type, the CDS entity represents a structured type with the elements of the CDS table function as components and can be used like any CDS entity.
In ABAP CDS, the CDS entity can be used as a data source of other CDS entities.
In ABAP, the CDS entity can be used as a data type and in AB-SQL read statements.
The CDS entity cannot be used as a data type for definitions of dictionary objects. A CDS table function is located in the namespace of all global types of an AS ABAP.
An AMDP function implementation CDS table functions are implemented in platform-dependent SQL in a special AMDP method and the implementation is managed as an AMDP table function by the AMDP in the database system. The AMDP method is specified after the addition IMPLEMENTED BY in the definition of the CDS table function using DEFINE TABLE_FUNCTION. It must be declared as a special AMDP function implementation for exactly one CDS table function using the addition FOR TABLE FUNCTION . The parameter interface of the AMDP table function is defined using the input parameters and the element list of the CDS table function.
A CDS table function is client-dependent by default and implicit client handling is applied in AB_SQL reads.



Latest notes:

CDS table functions can only be used in a database system that supports AMDP.
When a CDS table function is created, the CDS entity must be activated first, before the associated AMDP function implementation is created.
When a CDS table function is transported, the CDS entity is first transported at the same time as the dictionary transport objects and then the AMDP function implementation as part of the ABAP transport objects. Depending on the size of the transport, there can be a considerable delay between these two phases where the CDS table function is not in a usable state.
CDS table functions and CDS scalar functions are both implemented in an AMDP method as an AMDP function implementation . The differences between CDS table functions and CDS scalar functions are as follows:
CDS scalar functions return an elementary value, while CDS table functions return a tabular result type.
Different use cases:
- CDS table functions are used as a data sources in other CDS entities or in AB_SQL read statements.
- CDS scalar functions can be used in the same way as built-in functions, i.e. in operand positions that expect scalar values. Before the introduction of CDS scalar functions, users could define AMDP scalar functions, but they were not available in CDS entities. CDS scalar functions make scalar functions defined in AMDP known to ABAP Dictionary and available in ABAP CDS.
NON_V5_HINTS
ABAP_HINT_END