ABAP Keyword Documentation → ABAP − Reference → Processing Internal Data → Internal Tables → Expressions and Functions for Internal Tables → FILTER - Filter Operator → Examples of Table Filtering
Table Filtering, Filter Table
This example demonstrates table filtering using a filter table.
Other versions:
7.31 | 7.40 | 7.54
Source Code
init( ).
TYPES: BEGIN OF filter,
cityfrom TYPE spfli-cityfrom,
cityto TYPE spfli-cityto,
END OF filter,
filter_tab TYPE HASHED TABLE OF filter
WITH UNIQUE KEY cityfrom cityto.
DATA(filter_tab) = VALUE filter_tab(
( cityfrom = cityfrom cityto = cityto )
( cityfrom = cityto cityto = cityfrom ) ).
SELECT carrid, connid, cityfrom, cityto
FROM spfli
ORDER BY carrid, connid, cityfrom, cityto
INTO TABLE @DATA(spfli_tab).
cl_demo_output=>display(
FILTER #( spfli_tab IN filter_tab
WHERE cityfrom = cityfrom AND cityto = cityto ) ).
Description
Those rows are filtered out of an internal table spfli_tab
filled with flight
data that have specific values in the columns cityfrom
and cityto
.
The filter is applied using a filter table of the type filter_tab
constructed
using VALUE
filled with input values. The result is all outbound and return flights for the cities in question.