09-19-2017 10:50 AM
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.
09-19-2017 11:54 AM
09-19-2017 11:54 AM
09-19-2017 12:11 PM
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.
09-19-2017 12:53 PM
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.
09-19-2017 1:11 PM
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.
09-19-2017 1:42 PM
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)
09-19-2017 3:22 PM
Using method GET_FILTERED_ENTRIES you can get filtered values of the ALV. Exporting parameter ET_FILTERED_ENTRIES holds the filtered rows.