FILTER expression

Index

 

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.

FILTER_VarAll_source

Sample Source Code: Variant 1

FILTER_Var1_source

Output: Variant 1

FILTER_VarAll_outputFILTER_Var1_output

Sample Source Code: Variant 2

FILTER_Var2_source

Output: Variant 2

FILTER_VarAll_output

FILTER_Var2_output

Sample Source Code: Variant 3

FILTER_Var3_source

Output: Variant 3

FILTER_VarAll_output

FILTER_Var3_output

Sample Source Code: Variant 4

FILTER_Var4_source

Output: Variant 4

FILTER_VarAll_output

FILTER_Var4_output

Check the video for Illustration and Example:

Find the code on GitHub:

Go to Code

Index

 

Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s