cancel
Showing results for 
Search instead for 
Did you mean: 

ALV & Set focus

Former Member
0 Kudos

Hello,

I have a simple reporting web dynpro component. I am using the ALV functionality. The ALV output can be quite long and the user must scroll up & down the list when investigating list. When the user finds something interesting from the list, he will click a button in the ALV row, and this will open a popup window (=another web dynpro component).

The user can then do certain operations in the popup and click a button and this will update the data in the main component (the button will trigger an event, the event handler is in the main component, etc.). In other words the data in the ALV node will be updated. Now the user will close the popup, and here is the problem: the focus of the ALV is returned to the top of the list. So now the user needs to find again the same position in the report where he was before he opened the popup, and this is not user-friendly at all. I want to return the focus of the screen back to the same position where the users was before opening the popup.

Yes, I know that there is the method SET_FOCUS in the interface controller of the ALV component. Basically this methods does exactly what I am looking for. So basically if I was on row 50, I can set the focus back to row 50. Unfortunately SET_FOCUS method does not seem to be working properly when there is a popup window in use:

  • I am triggering an event from the popup component. The main component reacts to this method, does the calculations etc. and then updates the data used displayed by the ALV. Then I try to set the focus with the SET_FOCUS method. The method seems to be executed without problems, but as soon as the popup window is closed, the ALV is displayed starting from the first row.
  • Even if I do the following the SET_FOCUS is not working: Call the close_window method to close the window and then set the focus after that (I can even put a “WAIT UP TO 10 SECONDS” between these two operations, but the result is the same – actually the window is closed after 10 seconds…)

Can you suggest any workarounds for my problem? How to set the focus to certain row of an ALV after a popup window is closed?

Kind regards,

Karri

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Karri,

You can try using the following method of ALV.

IF_SALV_WD_TABLE_SETTINGS~SET_FIRST_VISIBLE_ROW

Before opening the pop up, you can keep the index of that row into some attribute, after returning back to main component, call the above method with the saved index.

In the thread below, Amy King has answered a question somewhat similar to yours. You can see that also, in case it helps.

http://scn.sap.com/thread/3256371

Regards,

Rohit

Former Member
0 Kudos

Hi Rohit,

Thanks for the hint. The SET_FIRST_VISIBLE_ROW method might actually work. I did just a simple test: I added a test button to my main component, and just hard coded to the action SET_FIRST_VISIBLE_ROW( '30'). Unfortunately this does nothing. The reason is that my ALV has been set up to show all rows (method SET_VISIBLE_ROW_COUNT( '-2' )).

If I set up my ALV to show e.g. only 50 rows, then SET_FIRST_VISIBLE_ROW( '30') works. It brings me to the row 30.

Now unfortunately I think I cannot change my ALV to have fixed amount of rows. My ALV list is so wide that users needs to use browser's horizontal scroll bar to see the last columns. If I set my ALV to have fixed amount of rows, there will be a vertical scroll bar in the ALV itself. So, if the users wants to scroll the ALV (up & down), he needs to first scroll right to be able to see the vertical scroll bar, and then he will not be able to see the first important columns any more. Not user friendly at all. At the moment when the ALV shows all rows, the user can use browser's vertical scroll bar, and this is pretty user friendly and fast.

Regards,

Karri

Former Member
0 Kudos

Hi Karri,

Maybe you can set visible row count at runtime (in initialize_alv_something method) to the exactly no of rows you need. If the no of rows is changing often you can rerun intialize_alv_something method on different events (ex: return from popup window).

I'm trying a lot these days to set focus on 2 salv_wd_table components (based on dynamic nodes, I want to set focus to a cell in alv1 on enter in a cell in alv2 and viceversa ). For one is working (enter in a cell in alv1 focus is set on a cell in alv2  - with set_focus method - but viceversa is not working;  even if the same code executed from button action is working ok. I did also the trick with wait up to n seconds but no result). Your post captured my attention and I'm wondering if there are some situations in which set_focus is not working properly or requires some prerequisites. I have a popup part but I'm not reached that part and thank you for sharing your problem. If I'll have the same problem your post will be very helpfull.

Regards,

Catalin Butnaru

Former Member
0 Kudos

Hi Karri,

It's me again. It seems that I found a workaroud for my problem. Hope it will help you. I set a timedtrigger element to trigger my button action (I told you above that the focus could be changed if I press on a button but not automatically after enter on cell). It's a little annoying because it has a 1 second delay but it works. Maybe you can set a timedtrigger to trigger your action - which set the focus - after you close the popup.

Regards,

Catalin Butnaru

Former Member
0 Kudos

Hi Catalin,

Thanks a lot for your suggestions.

First of all, I don't know which are the causes why the set focus method does not work sometimes. At least in my case it is clear that the popup somehow disturbs the process. I am quite sure that the focus is set correctly when the popup is still open, but once the web dynpro framework finally closes the window, the focus returns to the beginning of the ALV.

First I tried your suggestion to set the visible row count dynamically and then using the "set first visible row". This basically works, but it also caused some problems in my application with the vertical scroll bars, and the solution was not really user friendly.

Then I tried the TimeTriggered UI element. I was not familiar with this element before, but it was actually something that I was looking for - I just didn't know that it exists. Now I enable the TimeTriggered element for a moment when the window is closed, and in the action of this element I can set the focus of the ALV, and this seems to be working. Yes, it is a bit annoying with the delay, but at least the situation is much better than before.

Thanks again,

Karri

Answers (0)