Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Double click in alv grid not refreshing until I click elsewhere

Former Member
0 Kudos
631

Hello,

I'm very new to abap and just managed to partly implement double click in an alv grid.

I also created a button that calls the exact same function as double click (selects the row and fills in the data areas on the page). When I use the button, everything works fine, but when I double click, nothing changes until I click on a tab or other form of input button on the page.

I have followed the process in debugging and can't find the fault anywhere.

My double click is implemented by:

           create object lcl_event_receiver.
           set handler lcl_event_receiver->double_click
                for search_alv_grid.
          endif. 

CLASS lcl_event_handler DEFINITION.
    public section.
    methods:
    double_click         for event double_click
                         of cl_gui_alv_grid.
ENDCLASS.               "lcl_event_handler

 CLASS lcl_event_handler IMPLEMENTATION.
*---------------------------------------------------------------------*
*       METHOD double_click                                           *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
  method double_click.

  perform select_search_result.

  endmethod.                    "double_click
ENDCLASS.  

Any help would be much appreciated

1 ACCEPTED SOLUTION

Former Member
0 Kudos
144

Did you call the method REFRESH_TABLE_DISPLAY of CL_GUI_ALV_GRID in your method DOUBLE_CLICK?

9 REPLIES 9

nkr1shna
Contributor
0 Kudos
144

Hello,

Try using the template code given below. Let me know if you have any questions.

data : GT_EVENTS TYPE SLIS_T_EVENT.

  • get event

PERFORM BUILD_EVENT_TOPOFPAGE USING GT_EVENTS[].

  • display alv data

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = W_xxxxx

IT_FIELDCAT = GT_xxxx

IT_EVENTS = GT_EVENTS[]

TABLES

T_OUTTAB = T_xxxx

EXCEPTIONS

PROGRAM_ERROR = 1

OTHERS = 2.

  • get event perform

FORM BUILD_EVENT_TOPOFPAGE USING LT_EVENTS TYPE SLIS_T_EVENT.

DATA: LS_EVENT TYPE SLIS_ALV_EVENT.

*

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

I_LIST_TYPE = 0

IMPORTING

ET_EVENTS = LT_EVENTS.

  • Read double click event using the below statement

READ TABLE LT_EVENTS WITH KEY NAME = SLIS_EV_USER_COMMAND

INTO LS_EVENT.

IF SY-SUBRC = 0.

ENDIF.

ENDFORM. " BUILD_EVENT_TOPOFPAGE

FORM USER_COMMAND USING L_UCOMM LIKE SY-UCOMM

LS_SELFIELD TYPE SLIS_SELFIELD.

CASE L_UCOMM.

WHEN <double click>

Perform do_something.

ENDCASE.

ENDFORM. " USER_COMMAND

Best Regards,

Krishna

Former Member
0 Kudos
145

Did you call the method REFRESH_TABLE_DISPLAY of CL_GUI_ALV_GRID in your method DOUBLE_CLICK?

0 Kudos
144

yes, the function it calls does that. Though some of the fields it populates are just output fields not in alv grids.

0 Kudos
144

use event double_click from class cl_gui_alv_grid

define method with registring this event

0 Kudos
144

What is the I_CALLBACK_PROGRAM part of the reuse alv grid function?

Also when would I use this reuse_alv_grid_display?

Is that instead of the set_table_for_first_display?

Thanks for the help

0 Kudos
144

The difference between pressing the button on the GUI Status (on the screen) and the double click is that they raise and follow two different events:

1) The GUI status button acts only on the screen that has the ALV on it. During the processing of the button (USER_COMMAND) you can access the ALV object and refresh it.

2) The double-click and the REFRESH_TABLE_DISPLAY method acts only on the ALV object - not the screen that the ALV is on. The screen fields are not "refreshed" in this event. The only event that can update the screen (and its fields) is the PBO event of the screen.

Try adding i_appl_events = 'X' when you create the grid object:


    CREATE OBJECT grid1
           EXPORTING i_parent = custom_container1
                     i_lifetime = cl_gui_alv_grid=>lifetime_dynpro
                     i_appl_events = 'X'.

Then add the following code in your screen PAI (USER_COMMAND):


    case OK_CODE.
      .....
      when others.
      CALL METHOD cl_gui_cfw=>dispatch
              IMPORTING return_code = w_return_code.
      endcase.

What this will do is to trigger all events as application events i.e. screen events. If the screen does not handle those events, then the ALV events will be triggered by the CL_GUI_CFW=>DISPATCH.

Edited by: Ken Sanghvi on Dec 22, 2008 3:52 PM

0 Kudos
144

Hi,

What is the I_CALLBACK_PROGRAM part of the reuse alv grid function?

You use callback program to return back to the program which calls ALV grid. When you are using

events you can branch out of main program , this parameter will tell which is the main program which is

calling to display ALV.

Also when would I use this reuse_alv_grid_display? Is that instead of the set_table_for_first_display?

We will use this REUSE_ALV_GRID_DISPLAY to display contents of the internal table in ALV grid format.

Best Regards,

Krishna

0 Kudos
144

Thanks guys, I will have a go with what you've said and see where it gets me.

0 Kudos
144

Thanks everyone. Kens example got it working perfectly. Much appreciated