FILTER expression



ABAP HANA 7.51: FILTER expression

FILTER operator, in simple words, works as a SELECT statement on an Internal table. With the help of syntax, it produces an Internal table of specified TYPE for the specified condition in WHERE clause. Just like VALUE operator, it assumes two variants:

  1. Non-generic data type e.g. type can be defined before using it with FILTER keyword. The Type created using this mechanism is Structured or Table type.
  2. Using # character for type where operand position is fixed and identifiable

Addition EXCEPT is particularly useful in some of the scenarios where required result is the negation of available condition.

Below sample Source Code applicable for all the Variants below!

Below code defines a type called lty_filter with two fields field1 and field2. ltty_value is a table type of type lty_filter with unique keys as both the fields.

Tables type used for Filtering should be either be Sorted or Hashed by definition.

A table lt_value is created of table type ltty_value and 3 rows are inserted in it. A filter table lt_value_filter is also created which will be used for filtering data from lt_value using FILTER operator.


Sample Source Code: Variant 1


Output: Variant 1


Sample Source Code: Variant 2


Output: Variant 2



Sample Source Code: Variant 3


Output: Variant 3



Sample Source Code: Variant 4


Output: Variant 4



Check the video for Illustration and Example:

Find the code on GitHub:

Go to Code



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s