Show TOC Entering content frame

Background documentation Filters Locate the document in its SAP Library structure

With filters you restrict the display of data records in the ALV output. To do this, you specify conditions that a record in a specific field has to fulfill in order to be displayed or filtered out.

You are able to make the following settings for filter objects:

·        Create, get, or delete filter conditions for a field

·        Make settings for a filter condition

·        Forbid filters for a column

·        Filter according to the values of another field

·        Hide or show tab for filtering or pushbutton Filter in the toolbar (see Providing Standard ALV Functions)

Creating, Getting, or Deleting Filter Conditions for a Field

Unlike a sort condition, you can create as many filter conditions for each field as you want. 

Note

You are only able to create a filter condition for fields for which you have not expressly forbid this (see below

Filtering is a property of a field in the ALV output (see Field). To create, get, or delete the filter condition of a field, use the methods of the interface class IF_SALV_WD_FILTER (implementing class CL_SALV_WD_FIELD).

Methods for Creating, Getting, and Deleting Filter Conditions

Function

Method

Get a specific filter condition

GET_FILTER_RULE

Get all filter conditions of a field

GET_FILTER_RULES

Create filter condition

CREATE_FILTER_RULE

Delete a specific filter condition

DELETE_FILTER_RULE

The filter condition of a field is represented by an object of the class CL_SALV_WD_FILTER_RULE.

Note

If you assign a new data table with a new structure to your ALV output, all filter conditions for all fields are deleted automatically.

 Making Settings for a Filter Condition

A filter condition consists of the following specifications:

·        Comparison value with which the rows are tested

This can be an individual value or a range for the given value. You always enter the lower value (LOW_VALUE) and for a range, you enter an upper value too (HIGH_VALUE).

·        Operator for comparing the field value and the comparison value

This specification (OPERATOR) defines the relationship between the cell value and the comparison value (for example, greater than, less than or equal to)

·        Inclusion or exclusion

This specification defines whether rows that match the condition are displayed or not displayed.

To change settings for a filter condition, use the methods of the class CL_SALV_WD_FILTER_RULE.

Methods for Settings for a Filter Condition

Function

Method

Define comparison value (lower value)

SET_LOW_VALUE

Get comparison value (lower value)

GET_LOW_VALUE

Define upper value of comparison range

SET_HIGH_VALUE

Get upper value of comparison range

GET_HIGH_VALUE

Define operator

SET_OPERATOR

Get operator

GET_OPERATOR

Define inclusion or exclusion

SET_INCLUDED

Get inclusion or exclusion

GET_INCLUDED

Forbidding Filters for a Column

You can explicitly forbid filters for a field. This has the following effects:

·        When an ALV output is filtered, a filter row showing the current filter for each column is displayed. The user can use this filter row to quickly enter a filter.

If you forbid filtering for a field, the corresponding cell in the filter row is empty and cannot be filled.

·        The field in question is no longer available on the Filters tab of the Settings dialog box.

·        If you defined a filter condition for this field in your application, the filter in the ALV output has no effect.

To forbid filtering for a field, use the methods of the interface class IF_SALV_WD_FILTER (implementing class CL_SALV_WD_FIELD).

Methods for Forbidding Filtering

Function

Method

Forbid filtering for a field

SET_FILTER_ALLOWED

Check whether filtering is allowed

IS_FILTER_ALLOWED

Filtering According to the Values of Another Field

You can specify a field according to which the current field is to be filtered if the field itself fails to deliver the required result or requires overly complicated input. You use the methods of the interface class IF_SALV_WD_COLUMN_SERVICE_REF for this (implementing class CL_SALV_WD_COLUMN).

Methods for Sorting According to the Values of Another Field

Function

Method

Define field name of other field

SET_FILTER_FIELDNAME

Get field name of other field

GET_FILTER_FIELDNAME

 

 

 

Leaving content frame