ABAP Keyword Documentation → ABAP Dictionary → ABAP CDS in ABAP Dictionary → ABAP CDS - Views → ABAP CDS - DDL Statements → ABAP CDS - DEFINE VIEW
ABAP CDS - DEFINE VIEW, parameter_list
Other versions:
7.31 | 7.40 | 7.54
Syntax
... WITH PARAMETERS pname1 :
parameter_type, pname2 : parameter_type, ...
Effect
Defines input parameters pname1, pname2, ... in a CDS view in ABAP CDS in a comma-separated list. Each input parameter must be typed with a data type parameter_type. The name pname must comply with the naming rules for names. Furthermore, pname cannot contain any slash (/) characters and cannot be a reserved name in ABAP Dictionary. The reserved names that cannot be used are in the database table TRESE.
It is not case-sensitive. The blanks with in the comma-separated list are ignored and can be omitted.
An input parameter pname can be used as an operand in the following places in the SELECT statement of the view using the syntax :pname|$parameters.pname:
- Element in the SELECT list.
- Operand of an arithmetic expression.
- Operand operand directly after case in a case distinction.
- Right side of an expression cond_exp in a WHERE clause or HAVING clause.
- Right side of an expression cond_exp in an ON condition in an ABAP join or an association.
- Right side of an expression cond_exp in a filter condition of a path expression.
Notes
- If the view is used as a
- data source or in a path expression of a different CDS view or
- as a data source of a
SELECT
statement in ABAP
=
) is used instead of a colon (:).
- Views with parameters constitute a database extension that is not supported by all database systems.
However, the DDL of the ABAP CDS allows creating and accessing CDS views with parameters independent
of the database system. If
SELECT
is used to access a view of this type or a view that contains views with parameters as data sources but the current database system does support them, a non-handleable exception of the class CX_SY_SQL_UNSUPPORTED_FEATURE is raised.
- In an ABAP program, it is possible to use the method USE_FEATURES of the class CL_ABAP_DBFEATURES to check whether the current database system or a database system accessed using a secondary database connection supports views with parameters. This requires the constant VIEWS_WITH_PARAMETERS of the class to be passed to the method in an internal table.
- It is not currently possible to define optional input parameters or replacement parameters for input parameters.
Example
The following CDS view has a list of three input parameters used in the
WHERE clause of the SELECT statement.
For information about use in a SELECT
statement in ABAP, see SELECT
, CDS View with Input Parameters.
define view demo_cds_parameters
with parameters p_distance_l:S_DISTANCE,
p_distance_o:S_DISTANCE,
p_unit:S_DISTID
as select from spfli
{ key carrid,
key connid,
cityfrom,
cityto,
distance,
distid }
where distid = :p_unit and
distance between :p_distance_l
and :p_distance_o;