SAP NetWeaver AS ABAP Release 750, ©Copyright 2016 SAP AG. All rights reserved.
ABAP - Keyword Documentation → ABAP - Reference → Processing External Data → ABAP Database Accesses → Open SQL → Open SQL - Read Accesses → SELECT → SELECT - Examples →SELECT, CDS View with Input Parameters
This example demonstrates a read performed on a CDS view with pass by parameter.
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_o = @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.