Skip to Content
avatar image
Former Member

ALV & Set focus

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    avatar image
    Former Member
    Oct 31, 2012 at 10:04 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      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