0% found this document useful (0 votes)
14 views3 pages

CDS TABLE Function

Table function using CDS

Uploaded by

Pritam Saha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views3 pages

CDS TABLE Function

Table function using CDS

Uploaded by

Pritam Saha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

ABAP CDS Table Function Implemented by AMDP

ABAP CDS Table Function defines table function which are native to the database.

->The CDS table function has a set of input parameters and a set of return parameters . The
result is is a TABULAR format with return fields.

->Actual implementation happens in a AMDP method with a return value

-> Calling CDS Table Function to get the result

Step1. Create a DDL Source.

Select De ne Table Function with Parameters.


fi
> Provide the Input parameter list

-> Provide the return eld list

->Provide the [ AMDP ] CLASS=>METHOD that implements it.

->Activate it.

@EndUserText.label: 'Flight CDS with Table Function'


de ne table function zdemo_ ight_cds_tf
with parameters iv_carrid: s_carr_id
returns
{
mandt: s_mandt;
carrid: s_carr_id;
connid: s_conn_id;
countryfr: land1;
cityfrom: s_from_cit;
airpfrom: s_fromairp;
countryto: land1;
cityto: s_to_city;
airpto: s_toairp;
}
implemented by method zcl_demo_ ight_calculation=>get_details;

->The method must specify for which TABLE FUNCTION it is used.

->Implement the AMDP method with RETURN.

CLASS zcl_demo_ ight_calculation DEFINITION


PUBLIC
FINAL
CREATE PUBLIC .

PUBLIC SECTION.

INTERFACES: if_amdp_marker_hdb.

CLASS-METHODS: get_details FOR TABLE FUNCTION ZDEMO_FLIGHT_CDS_TF.

PROTECTED SECTION.
PRIVATE SECTION.

ENDCLASS.
fi
fl
fi
fl
fl
CLASS zcl_demo_ ight_calculation IMPLEMENTATION.

METHOD get_details BY DATABASE FUNCTION


FOR HDB
LANGUAGE SQLSCRIPT
OPTIONS READ-ONLY
USING sp i.
RETURN

SELECT mandt, carrid, connid,


countryfr, cityfrom, airpfrom,
countryto, cityto, airpto
FROM sp i WHERE carrid = iv_carrid;

ENDMETHOD.

ENDCLASS.

Calling the CDS Table Function from PROGRAM/METHOD with addition :

##db_feature_mode[amdp_table_function]

SELECT *
FROM zdemo_ ight_cds_tf( iv_carrid = 'LH' )
INTO TABLE @DATA(lt_ ight)
##db_feature_mode[amdp_table_function].

cl_demo_output=>display_data( EXPORTING value = lt_ ight ).

Output:
fl
fl
fl
fl
fl
fl

You might also like