WHERE - (cond_syntax)

Syntax

... (cond_syntax) ...

Effect

A logical expression can be specified as a parenthesized data object cond_syntax that contains the syntax of a logical expression or is initial when the statement is executed. It has been possible since SAP Web AS 6.40 to specify all logical expressions dynamically, with the exception of the evaluation of a subquery.

In particular, the logical expression in cond_syntax can also be combined using AND or OR or negated using NOT. The data object cond_syntax can be a character-type data object or an internal table with a character-type data type. The syntax in cond_syntax is, as in the ABAP Editor, not case-sensitive. In the case of the specification of an internal table, the syntax can be spread across multiple rows.

The result of the logical expression (cond_syntax) is determined by the result of the contained logical expression. If cond_syntax is initial when the statement is executed, the logical expression is true.

Notes

Example

Creating a dynamic comparison from user input. In the case of incorrect syntax or incorrect semantics, exceptions are generated, which are handled using the common superclass.

PARAMETERS: column TYPE c LENGTH 8,
            value  TYPE c LENGTH 30.

DATA spfli_wa TYPE spfli.

DATA cond_syntax TYPE string.

CONCATENATE column '= value'
            INTO cond_syntax SEPARATED BY space.

TRY.
    SELECT SINGLE *
           FROM spfli
           INTO spfli_wa
           WHERE (cond_syntax).
  CATCH cx_sy_dynamic_osql_error.
    MESSAGE `Wrong WHERE condition!` TYPE 'I'.
ENDTRY.