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
Other versions:
7.31 | 7.40 | 7.54
Syntax
... ( pname1 = act1, pname2 = act2, ... ) ...
Effect
Specifies actual parameters act1
, act2
, ... for
input parameters pname1
, pname2
, ... of a
CDS entity in a parenthesized
comma-separated list. Parameters can be passed to non-abstract CDS entities in the following positions in ABAP SQL statements:
- After a CDS entity as the data source of the
FROM
clause of a query.
- After the CDS associations of a path expression in the
data source of the
FROM
clause and in the specified columns of a query.
If a CDS entity has input parameters as the data source data_source
of a
query or target of a CDS association specified in a
path expression, a matching actual parameter must be passed to each input parameter as follows:
- If an input parameter does not have an annotation @Environment.systemField, an explicit actual parameter must be specified.
- If an input parameter has an annotation
@Environment.systemField with one of the predefined values
#SYSTEM_..., an explicit actual parameter does not need to be specified.
If no actual parameter is specified, ABAP SQL passes the nominal value of the system field assigned
using the annotation implicitly. Here, only the date and time are taken from the system fields
sy-datum and
sy-uzeit
and the language and user name are taken from secure sources.
- If an input parameter has an annotation
@Environment.systemField with the predefined value
#CLIENT, an explicit actual parameter must not be specified. Instead, ABAP SQL passes the ID of the current
client
or a client specified using
USING CLIENT
implicitly.
Literals, host variables, or
host expressions can be specified as actual
parameters. The name of a host variable must be prefixed with the escape character @
. The data type of the parameter must be convertible into the
built-in data type in ABAP Dictionary; the built-in data type is specified by the
typing of the parameter. The content of the actual parameter must match the data type of the input parameter in accordance with the rules for a
lossless assignment.
In the following cases, the parentheses ( )
after the name of a CDS entity can be empty or omitted:
- The function is a CDS table function without input parameters.
- The view is a CDS view with input parameters that are all filled implicitly using the annotation @Environment.systemField.
Parentheses cannot be specified in CDS views without input parameters or in any classic dictionary objects.
Notes
- There are currently no optional input parameters for CDS entities and no real replacement values for input parameters. The annotation @Environment.systemField bypasses this gap for some environment values by providing the caller with the non-optional parameters implicitly.
- Currently, a path expression in a specified column in a query cannot contain any CDS associations for entities with input parameters.
- When parameters are passed to a entity with parameters, the syntax check is performed in strict mode from 7.40 SP08. If a host expression is specified as an actual parameter, the syntax check is performed in strict mode from Release 7.50. If a path expression is also used, or a parameter is passed in a path expression, the syntax check is performed in strict mode from Release 7.52.
Example
Passes a time zone to the input parameter tz of the CDS view demo_cds_assoc_sairport_tz.
DATA timezone TYPE s_tzone VALUE 'UTC+1'.
cl_demo_input=>request( CHANGING field = timezone ).
SELECT id
FROM demo_cds_assoc_sairport_tz( tz = @timezone )
INTO TABLE @DATA(result).
cl_demo_output=>display( result ).
Executable Example
SELECT
, CDS View with Input Parameters