Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Use filtered ALV table data in OOP

Former Member
0 Kudos

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.

1 ACCEPTED SOLUTION

raymond_giuseppi
Active Contributor

Use method get_filtered_entries.

6 REPLIES 6

raymond_giuseppi
Active Contributor

Use method get_filtered_entries.

0 Kudos

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.

0 Kudos

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.

0 Kudos

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
      lo_alv_grid->get_filtered_entries(
        IMPORTING
          et_filtered_entries = DATA(lit_index)
      ).

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

0 Kudos

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_sahoo3
Contributor
0 Kudos

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