Get Example source ABAP code based on a different SAP table
• IN FILTER
FILTER>, Filter Table
ABAP_SYNTAX ... FILTER type( itab ${$[EXCEPT$] IN ftab $[USING KEY keyname>$]$} $| ${$[USING KEY keyname>$] $[EXCEPT$] IN ftab$} WHERE c1 op f1 $[AND c2 op f2 $[...$]$] ) ...>
ABAP Addition 1 ... USING KEY keyname> 2 ... WHERE c1 op v1 $[AND c2 op v2 $[...$]$]>
What does it do? This variant of the filter operator FILTER>> filters itab > using values from an internal table ftab>. In the WHERE> condition, the columns of itab> are compared with the values of the columns of the table key of the lines of the filter table ftab >. Those lines in itab> are used for which at least one line in ftab> meets the WHERE> condition or for which there is no line in ftab> when EXCEPT> is specified. ftab> is a functional operand position>. Depending on its position, USING KEY> can be used to specify either a key of the table ftab> or the table itab>, which is then used to access the table. If USING KEY> is not used, the filter table ftab> must have a sorted key> or a hash key> as the primary table key>, which is then used to access the filter table.
Latest notes: The line types of itab> and ftab> do not need to be identical. NON_V5_HINTS ABAP_HINT_END
ABAP_EXAMPLE_VX5 Filtering of three lines of the internal table carriers>. The filter table has a sorted primary key. This is used implicitly and the addition USING KEY> does not have to be specified. ABEXA 00908 ABAP_EXAMPLE_END
ABAP Addition
What does it do? Specification of the table key keyname>> with which the WHERE> condition is evaluated. A sorted key or a hash key of the filter table can be specified after ftab> or of the source table after itab>. This can be the primary table key> or a secondary table key> that is specified using primary_key> or the corresponding name.
When USING KEY> is specified for the filter table ftab>, it must have a sorted key> or a hash key>. There are no requirements on the table keys of itab>. The specified key is used to access the filter table.
When USING KEY> is specified for the source table itab>, it must have a sorted key> or a hash key>. There are no requirements on the table keys of ftab>. The specified key is used to access the source table.
If USING KEY> is not specified for ftab> or itab>, the filter table ftab> must be a sorted table or a hashed table and the primary table key is used implicitly when accessing the filter table. There are no requirements on the table keys of itab>.
Latest notes: The tables for which a key is specified depends on the optimization to be achieved. NON_V5_HINTS ABAP_HINT_END
ABAP_EXAMPLE_VX5 Like the previous example, but here the addition USING KEY> must be used for one of the tables, since the internal table filter> is a standard table without a primary key. ABEXA 00909 ABAP_EXAMPLE_END
ABAP_EXAMPLE_VX5 Like the previous example, but here the addition USING KEY> is used for the other table. ABEXA 00910 ABAP_EXAMPLE_END
ABAP Addition
What does it do? A condition for the table key used in the FILTER> expression must be specified after WHERE>:
In the case of a hash key, exactly one comparison expression> c op f> for each key component. The only comparison operator> allowed for op > is =>>.
In the case of a sorted key, an initial part of the key must be covered by comparison expressions> c op f>. op> can be any binary comparison operator>. Multiple comparisons can only be combined using AND>> only. There can be no further comparisons apart from those mentioned for key components. In the variant with the filter table, key components of the filter table ftab> must be specified for the right operands f1>, f2>, .... On the left side, components of the internal table itab> must be specified that are compatible with the right side.
Latest notes:
The Boolean operators NOT>>, OR>>, and EQUIV> > cannot be used in the WHERE> condition. NON_V5_HINTS
The obsolete comparison operators> cannot be used in the WHERE> condition. ABAP_HINT_END
ABAP_EXAMPLES_ABEXA
Table Filtering, Filter Table>
Table Filtering, Filterings with Filter Table> ABAP_EXAMPLE_END