parameter_list
is used to declare a list of optional input parameters for the CDS table function. These also define the input parameters of the AMDP function.
element_list
is used to declare the elements of the CDS table function. These also define the columns of the tabular return value of the AMDP function.
When amdp_function is used, an
AMDP function implementation
must be specified in the form amdp_class=>amdp_method. Here amdp_class is an
AMDP class and amdp_method is an
AMDP function implementation contained in this
class. When this function implementation is declared, the current CDS table function is specified after
the addition FOR TABLE
FUNCTION. The AMDP function implementation must not exist when the CDS table function is
created and activated. . The name of an AMDP function implementation amdp_function can only be specified in a single CDS table function.
A CDS table function returns a tabular result set. This can be used (like every
CDS entity) as a data source in other CDS entities or in
Open SQL read statements. The prerequisite for use is that the specified AMDP function implementation exists and is active.
Table functions constitute a database extension that is not supported by all database systems. However,
the CDS DDL in ABAP CDS allows table functions to be created and accessed independently of the database
system. If SELECT is used to access
a table function or a view that contains table functions as data sources but the current database system
does not support them, a non-handleable exception of the class CX_SY_SQL_UNSUPPORTED_FEATURE is raised.
In an ABAP program, it is possible to use the method USE_FEATURES of the class
CL_ABAP_DBFEATURES to check whether the current
database system supports table functions. This requires the constant AMDP_TABLE_FUNCTION of the class to be passed to the method in an internal table.
If a CDS role is defined
for a CDS entity using the CDS DCL statement DEFINE ROLE, implicit
access control is
applied by default when the CDS entity is accessed using Open SQL. CDS access control can be switched
off using the value #NOT_ALLOWED for the annotation @AccessControl.authorizationCheck and using the addition WITH PRIVILEGED ACCESS in the FROM clause of an Open SQL query
The DDL source code
of a CDS table function does not need to have the same name as the CDS table function, but it is advisable to use the name of the CDS table function.
After a piece of DDL source code is transported, the combination of its name and the name of the CDS table function view is defined and can no longer be modified by being renamed.
Example
The following DDL source code shows a client-specific
CDS table function. It contains an input parameter (with the annotation@Environment.systemField and the predefined value #CLIENT) for the client, which is implicitly supplied with the ID of the current client when used as a
data source of the Open SQL statement SELECT. For more information about how to use this function, see the executable example for AMDP Functions.