Skip to Content

Use filtered ALV table data in OOP

Sep 19, 2017 at 09:50 AM


avatar image

Is there an easy way of retrieving the ALV data that is displayed when there are also filters used on that ALV?

The ALV is an object of CL_GUI_ALV_GRID. When showing it to the user, there is a filter placed on it by default. The user also has a button that processes the data in the ALV. How can I make sure the process only works with the data that is displayed, even if the user places his own filters on the ALV?

e.g: An ALV gets created from an itab that has 10 rows, but because there is also a filter passed on the ALV, only 8 rows are showing. When pressing a button, I only want to work with the 8 rows currently showing to the user.

Thanks in advance.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Best Answer
Raymond Giuseppi
Sep 19, 2017 at 10:54 AM

Use method get_filtered_entries.

Show 4 Share
10 |10000 characters needed characters left characters exceeded

Thanks, that is already really helpful, but this method gets me the entries that are NOT displayed. How would I best translate this to the displayed entries? I think filling a table with entries not displayed, copying the source table and then looping through this copy and checking if they are in the non-displayed entries to delete them is a little bit timeconsuming.


Usually I loop in the internal table and for each record check if it's hidden (in the filtered entries) The other solution is build a second itab so the check is only executed once, it depends on your program layout.


I ended up copying the source table, looping over the filtered entries and deleting those indexes from the copy of source.

      " Copy original table
      DATA(lit_buffer) = lt_disp_items.

      " Get excluded rows
          et_filtered_entries = DATA(lit_index)

      " Remove excluded rows from buffer
      LOOP AT lit_index ASSIGNING FIELD-SYMBOL(<index>).
        DELETE lit_buffer INDEX <index>.


Be aware that deleting a row will change the index value of following rows... (you could sort/loop filtered entries by index descending among many other tricks to solve this one)

Satyabrata Sahoo Sep 19, 2017 at 02:22 PM

Using method GET_FILTERED_ENTRIES you can get filtered values of the ALV. Exporting parameter ET_FILTERED_ENTRIES holds the filtered rows.

10 |10000 characters needed characters left characters exceeded