Get Example source ABAP code based on a different SAP table
VERSION 5 IN • DEFINE TABLE FUNCTION ABAP_CDS_DDL_STATEMENT • IMPLEMENTED BY METHOD ABAP_CDS_DEFINE_TABFNC
ABAP_CDS_DDL - DEFINE TABLE FUNCTION
ABAP_SYNTAX $[@entity_annot1$] $[@entity_annot2$] ... $[@function_annot1$] $[@function_annot2$] ... $[DEFINE$] TABLE FUNCTION table_function $[parameter_list$] element_list IMPLEMENTED BY METHOD amdp_function $[;$]
What does it do? Defines a CDS entity table_function as a CDS table function in the CDS DDL. In platform-dependent SQL, the CDS table function is implemented in an AMDP method amdp_function, which is created using the AMDP framework in the database system as an AMDP table function. The name table_function must comply with the naming conventions for dictionary types and can have a maximum of 30 characters.
@entity_annot and @function_annot are used to specify optional annotations for the CDS table function.
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 table 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 table function.
When amdp_function is used, an AMDP function implementation must be specified for an AMDP table function 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 be specified in a single CDS table function only. A CDS table function returns a tabular result set. Like any CDS entity, it can be used as a data source in other CDS entities or AB-SQL read statements. The prerequisite for use is that the specified AMDP function implementation exists and is active. The name of a CDS table function is located in the namespace of all global types of an AS ABAP.
Latest notes:
If a CDS role is defined for a CDS entity using the CDS-DCL statement DEFINE ROLE, implicit access control applies by default when the CDS entity is accessed using AB-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 AB-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. NON_V5_HINTS
No ABAP Dictionary DDIC structure visible in the tools for structures is created for a CDS table function. ABAP_HINT_END
ABAP_EXAMPLE_VX5 The following DDL source code shows a client-dependent 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 AB-SQL statement SELECT. For more information about how to use this function, see the executable example for AMDP Functions. DDLS DEMO_CDS_GET_SCARR_SPFLI_INPCL ABAP_EXAMPLE_END