How To Use AMDP in CDS Table Function
How To Use AMDP in CDS Table Function
PUBLIC SECTION.
INTERFACES if_amdp_marker_hdb.
CLASS-METHODS get_scarr_spfli_for_cds
FOR TABLE FUNCTION demo_cds_get_scarr_spfli_inpcl
IMPORTING
VALUE(carrid) TYPE /dmo/carrid
EXPORTING
VALUE(result) TYPE /dmo/tt_scarr_spfli_inpcl.
ENDCLASS.
ENDMETHOD.
ENDCLASS.
This AMDP function uses SQLScript to query data from three tables
(/dmo/scarr, /dmo/spfli, and /dmo/sbook) and returns the result as a table
parameter. The function takes one input parameter (carrid) which is used to
filter the data.
To consume the CDS table function, you can use the following syntax:
"AMDP table function selected via CDS entity
SELECT * FROM demo_cds_get_scarr_spfli_inpcl (carrid = @carrid)
INTO TABLE @DATA (result2) ##db_feature_mode
[amdp_table_function].
ASSERT result1 = result2.
cl_demo_output=>write (result1).
This code snippet selects data from the CDS table function using the input
parameter carrid and stores the result in an internal table result2. The
##db_feature_mode pragma is used to indicate that the CDS entity is an
AMDP table function .
I hope this example helps you understand how to use AMDP in CDS table
function. For more information, you can refer to the following links:
: AMDP Function and CDS Table function | SAP Blogs : AMDP, AMDP Functions
- ABAP Keyword Documentation - SAP Online Help : Table Functions and
AMDP | SAP Help Portal : Consume CDS View inside CDS Table Function by
using AMDP