ABAP - Keyword Documentation →  ABAP - Dictionary →  ABAP CDS in ABAP Dictionary →  ABAP CDS - Data Definitions →  ABAP CDS - DDL for Data Definitions → 

ABAP CDS - DEFINE TABLE FUNCTION

Syntax

[@function_annot1]
[@function_annot2]
...
[DEFINE] TABLE FUNCTION cds_entity
         [parameter_list]
         element_list
         IMPLEMENTED BY METHOD amdp_function [;]

Effect

Defines a CDS table function in the CDS DDL. In platform-specific 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 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.

A CDS table function is in the namespace of the data types in ABAP Dictionary and of the global object types in the class library.

Notes

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.

@ClientHandling.type: #CLIENT_DEPENDENT
define table function DEMO_CDS_GET_SCARR_SPFLI_INPCL
  with parameters
    @Environment.systemField: #CLIENT
    clnt   :abap.clnt,
    carrid :s_carr_id
  returns
  {
    client   :s_mandt;
    carrname :s_carrname;
    connid   :s_conn_id;
    cityfrom :s_from_cit;
    cityto   :s_to_city;
  }
  implemented by method
    CL_DEMO_AMDP_FUNCTIONS_INPCL=>GET_SCARR_SPFLI_FOR_CDS;


Continue
ABAP CDS - DEFINE TABLE FUNCTION, function_annot
ABAP CDS - DEFINE TABLE FUNCTION, parameter_list
ABAP CDS - DEFINE TABLE FUNCTION, element_list