Mentor SAP
An ABAP program can use the CDS table function as the data source in the from clause of a SELECT statement- just like it would do with a CDS view, database view, or transparent table.

 

The CDS framework executes the SELECT from the CDS table function by calling the assigned function on the database.

 

The example shows the definition of a CDS table function. From the outside, it looks like the definition of a CDS View with an input parameter name_in and an element list with the three fields mandt, id and name.

 

 

An AMDP method that implements a CDS table function is defined without parameters. Instead, addition FOR TABLE FUNCTION…is used. The signature of the AMDP method is then taken from the CDS table function.

 

Template defineTableFunctionWithParameters

 

When creating a new DDL Source for a CDS table function, you are supported by a dedicated template.

 

Creating a CDS Table Function

When developing a CDS table function, it is most important to do it in the right order.

 

CDS Table Function in Open SQL

 

In Open SQL, you can use CDS table functions like any other CDS view. But you have to be aware that the underlying AMDP functions are not supported by all databases.

 

If a CDS table function is accessed in a system that does not support this feature, a runtime error occurs. You can catch this runtime error via the exception class. CX_SY_SQL_UNSUPPORTED_FEATURE.

 

 

To make you aware of this risk, ABAP syntax check issues a warning whenever a program accesses a CDS table function. These warnings are not restricted to direct use of the table function. If you access an ordinary CDS view that uses table function as its data source, the system issues the same warning.

 

If there is the slightest chance that your coding might run on systems that do not support AMDP functions, use the service method of class CL_ABAP_DBAFEATURES to check the system capability. If it doesn’t stop program execution or provide an alternative coding.