Skip to content

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:


Notes

  • If the view is used as a
each input parameter must be assigned a suitable actual parameter whose value is then used in the operand positions in which the parameter is specified. The actual parameters are assigned using a parenthesized comma-separated list
... cds_entity( pname1 : act1, pname2 : act2, ...) ...,
that must be specified directly after the name of the view when using a view with parameters (both within the DDL in ABAP CDS and in Open SQL). In Open SQL , an equals sign (=) 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.

@AbapCatalog.sqlViewName: 'DEMO_CDS_PARA'
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;

Continue

ABAP CDS - DEFINE VIEW, parameter_type