cancel
Showing results for 
Search instead for 
Did you mean: 

ALV Aggregation & First Visible Row

Former Member
0 Kudos

Hi,

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.

Regards,

Karri

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member184578
Active Contributor
0 Kudos

Hi,

You called the method SET_FIRST_VISIBLE_ROW in the First view during navigation?

Try to call the method SET_FIRST_VISIBLE_ROW in the WDDOMODIFYVIEW of Second View.

If still the aggregation is overwriting, One work around would be Remove the aggregation and Do manual calculation by looping the internal table and append the Final Record with total to the internal table and Bind it to the ALV.

Regards,

Kiran

Former Member
0 Kudos

Hi,

I have tried to call the SET_FIRST_VISIBLE_ROW from various different method including the WDDOMODIFYVIEW of second view, but this has not effect.

I cannot replace the standard aggregation with own coding. I have also subtotal aggregate values (based on the sorting), so there is not just one total value at the end of the ALV list (which would be easy to calculate). Also, the standard sorting functionality works nicely with the aggregation, and if I built my own total calculation, I would loose this functionality.

One interesting thing that I just found: If I navigate to the second view, and the scroll for example to the first row, and then navigate back to the first view, and then do the same selection again, and navigate to the second view again => Now the ALV remembers that I was in the first row, so it displays the first 20 rows. (Maybe if I could somehow fool the system that I have already been in the ALV view once...)

Regards,

Karri

former_member184578
Active Contributor
0 Kudos

Hi,

Interesting! As you said after Displaying ALV in second view and calling SET_FIRST_VISIBLE_ROW method in onAction of Button it's working fine.

So, instead of creating extra button, create a Timed Trigger UI and set Delay Property to 1. Then in onAction of Timed Trigger UI call the SET_FIRST_VISIBLE_ROW method so that it appears the first rows are set automatically.

Also don't forget to deactivate the Timed Trigger after that.

Regards,

Kiran

Former Member
0 Kudos

Hi,

Actually I am already using the timed trigger solution that you present. I works quite nicely, but of course it is a bit annoying because first the last rows of the ALV are displayed, but then after one second, the first rows appear. Acceptable but not perfect.

I am looking for a way to prevent the problem completely.

Thanks any way. The timed trigger is currently my solution to this problem.

Regards,

Karri