AS ABAP Release 754, ©Copyright 2019 SAP SE. All rights reserved.
ABAP Keyword Documentation → ABAP − Reference → Processing External Data → ABAP Database Access → ABAP SQL → ABAP SQL - Operands and Expressions → ABAP SQL - SQL parameter passing sql_para →ABAP SQL, Parameter Passing to a CDS View
This example demonstrates a read performed on a CDS view using parameter passing.
Source Code
REPORT demo_cds_parameters.
CLASS demo DEFINITION.
PUBLIC SECTION.
CLASS-METHODS main.
ENDCLASS.
CLASS demo IMPLEMENTATION.
METHOD main.
DATA:
from_distance TYPE s_distance VALUE 2000,
to_distance TYPE s_distance VALUE 6000,
unit TYPE s_distid VALUE 'MI'.
cl_demo_input=>new(
)->add_field( CHANGING field = from_distance
)->add_field( CHANGING field = to_distance
)->add_field( CHANGING field = unit
)->request( ).
SELECT *
FROM demo_cds_parameters( p_distance_l = @from_distance,
p_distance_u = @to_distance,
p_unit = @unit )
ORDER BY carrid, connid
INTO TABLE @DATA(result).
cl_demo_output=>display( result ).
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
demo=>main( ).
Description
SELECT is used to access a CDS view with parameters as a data source. Actual parameters are assigned to the input parameters of the view. The values of these actual parameters can be defined by input.
The view in question, demo_cds_parameters, has the following CDS source code with a list of input parameters:
This means that those rows are read from the database table SPFLI whose distance in the passed unit is located between the two passed values.