Skip to Content
Former Member
Aug 13, 2013 at 04:43 AM

ALV Aggregation & First Visible Row



I have a component with two views. The first view includes few select options and a button. When the button is clicked, a selection is done and the results are displayed in the second view in an ALV table. So, a very basic setup. I have limited the visible rows of the ALV to fixed amount (let's say it is 20 visible rows). I am also using aggregation and sorting to display calculated (sub)total amounts of certain column.

Now my problem is that when I navigate to the second view including the ALV table and the result is more than 20 rows, the table is displaying the last 20 rows. So, if my result has 100 rows, then the last 81-100 are displayed. If I want to display the first rows, I need to scroll the table. This is something that I don't want. I need to display the the first 20 rows initially.

As far as I understand, this problem is caused because of the aggregation. If I remove the aggregation functionality from the code, then the first 20 rows are displayed just I would like my ALV to work with the aggregation functionality. I found a thread where it was mentioned that if aggregation is used, then the aggregation result is displayed by default (=last rows of the table are displayed).

Is there a workaround for this problem? How can I display the first rows by default?

The obvious SET_FIRST_VISIBLE_ROW method is not working! I have tried to call the method and set the first visible row as 1 in numerous hook methods of the view and during the navigation to the second view, but it seems that the aggregation result is always displayed by detault. The framework overwrites the set_first_visible_row functionality. Interesting thing is that I can call the method after the ALV (second view) has been displayed. So for example I can add a button "Go to the first row" (=>and call the SET_FIRST_VISIBLE_ROW method) to the second view, and it will work. But during the navigation from first to second view & ALV generation the method will not work.