SAP WHERE STATIC ABAP Statements

Get Example source ABAP code based on a different SAP table
  


ABAP Code Snippet

What does it do? Static WHERE condition. All rows are processed for which the condition after WHERE is met. WHERE can be specified for all table categories.

A logical expression log_exp can be specified after WHERE, in which the first operand of each relational expression is a component of the internal table. Any comparison expression and the predicate expression IS INITIAL can be specified as relational expressions. Other predicates cannot be specified. The components of the internal table must be specified as individual operands and not as part of an expression. Parenthesized character-like data objects cannot be used to specify a component dynamically here. The remaining operands of a relational expression are general expression positions at which any suitable individual operands or expressions can be specified, but no components of the internal table. The specified components can have any data type. The relevant comparison rules apply to the evaluation.
When standard tables are accessed without a secondary key being specified, the access is not optimized. This means that all rows of the internal table are tested for the logical expression of the WHERE addition.
When using a sorted key or a hash key (that is, when accessing a sorted table, a hashed table, or a secondary table key), an attempt is made to optimize the access as described under Optimization of the WHERE Condition. If the following prerequisites are not met:
the entire logical expression (or a part of the expression) can be transformed to a key access,
the transformable part of the logical expression has the same result as the resulting key access, no optimization takes place when a sorted table or a hashed table is accessed using the primary table key . Any access using a secondary table key produces a syntax error or exception. In the part of the logical expression relevant for the optimization, the static WHERE condition cannot specify any duplicate or overlapping keys. Duplicate key components can, however, be specified in the part of the logical expression whose relational expressions do not make a contribution to the optimized access.

Latest notes:When using a WHERE condition, note that the comparison rules for incompatible data types apply when comparing incompatible data objects. Here, the data types involved determine which operand is converted. If the additions WITH TABLE KEY and WITH KEY of the statement READ are used or if the appropriate keys are specified in table expressions, however, the content of the specified data objects is always converted to the data type of the columns before the comparison. This can produce varying results. If possible, all operands of the logical expression should be in compatible pairs, so enabling the WHERE condition to be optimized . If a comparison expression with a selection table is specified after IN as a logical expression, note that the expression at the initial table is always true and then all rows are edited.

Return to menu