Calling CDS view in program( SQL Query)
We have the CDS view CDS view with Parameter . Now let’s use this CDS view in the report/program select query.
Program Code:
To check if DB supports VIEWS_WITH_PARAMETERS usually class CL_ABAP_DBFEATURES is used but now we can directly use ##db_feature_mode[views_with_parameters] as a part of SQL query.
PARAMETERS: p_carr type sflight-carrid.
START-OF-SELECTION.
“if ( CL_ABAP_DBFEATURES=>use_features(
” requested_features = VALUE #( ( “CL_ABAP_DBFEATURES=>VIEWS_WITH_PARAMETERS ) ) ) = abap_true ).
select * FROM Zflight_Param_View( flight_code = @p_carr )
into TABLE @DATA(lt_flight) ##db_feature_mode[views_with_parameters].
cl_demo_output=>display_data(
EXPORTING
value = lt_flight
name = ‘Flight CDS View with Input Parameters’ ).
“endif.
Output.