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: 

help on Double click functionality in ALV Grid in OOPS

Former Member
0 Kudos

Hi all,

can anybody share your experience on the functionality i am looking for in OOPS using ALV GRID .

any example will be more helpful.

i want to double click the output in the ALV grid output ( this i have accomplished ) .

in my program i am accessing a custom class created in SE24 .

when i double click this goes into the class and the method it is associated but it is not identifying the grid from which it is double clicked .

Please suggest .

Regards,

Ry

13 REPLIES 13

Former Member
0 Kudos

Hi,

You have to use the SET HANDLER to link..

Also check the program BCALV_TEST_GRID_EVENTS..

Ex..

CREATE OBJECT lcl_event_receiver.

SET HANDLER : lcl_event_receiver->handle_double_click FOR g_report_grid.

Thanks

Naren

0 Kudos

Hi Naren,

Thanks for your input , but the problem is i have two screens like grid1 and grid2 in the output .

if i double click on grid1 , the sender parameters should identify as grid1 based on i will perform the relevant action . but i am not able to figure that . please suggest.

thanks

Ry

Former Member
0 Kudos

check this...



    CREATE OBJECT gr_ccontainer
    EXPORTING
    container_name = gc_custom_control_name
    EXCEPTIONS
    cntl_error = 1
    cntl_system_error = 2
    create_error = 3
    lifetime_error = 4
    lifetime_dynpro_dynpro_link = 5
    OTHERS = 6 .

    CREATE OBJECT gr_alvgrid
    EXPORTING
    i_parent = gr_ccontainer
    EXCEPTIONS
    error_cntl_create = 1
    error_cntl_init = 2
    error_cntl_link = 3
    error_dp_create = 4
    OTHERS = 5 .

    CREATE OBJECT gr_event_handler.
    SET HANDLER gr_event_handler->handle_double_click FOR gr_alvgrid. " Take a look!!

    PERFORM prepare_field_catalog CHANGING gt_fieldcat .
    PERFORM event_build USING alv_eventsmp[] 'TOP_OF_PAGE4'.

    PERFORM prepare_layout CHANGING gs_layout .
    CALL METHOD gr_alvgrid->set_table_for_first_display
      EXPORTING
        is_layout                     = gs_layout
      CHANGING
        it_outtab                     = ti_log[]
        it_fieldcatalog               = gt_fieldcat
      EXCEPTIONS
        invalid_parameter_combination = 1
        program_error                 = 2
        too_many_lines                = 3
        OTHERS                        = 4.

.....

" on some other part of your code....


CLASS lcl_event_handler DEFINITION .
  PUBLIC SECTION .
    METHODS:
*--Double-click control
    handle_double_click
    FOR EVENT double_click OF cl_gui_alv_grid
    IMPORTING e_row e_column es_row_no.

ENDCLASS.                    "lcl_event_handler DEFINITION
*----------------------------------------------------------------------*
*       CLASS lcl_event_handler IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_event_handler IMPLEMENTATION .

*--Handle Double Click
  METHOD handle_double_click .
    PERFORM handle_double_click USING e_row e_column es_row_no. " Implement it.
  ENDMETHOD .                    "handle_double_click

Bye

Gabriel

0 Kudos

Hi Gabriel,

in your code u wanted to create object gr_event_handler.

what is the type ref to for gr_event_handler.

Regards,

Ry

0 Kudos

Hello,

Sorry I skiped that part....

DATA gr_event_handler TYPE REF TO lcl_event_handler.

It is the class I created for event handling.

Bye

Gabriel P.-

Edited by: Gabriel P.- on Oct 10, 2008 4:03 PM

0 Kudos

Hi Gabriel,

instead of writing it in a local class , i have written the double click functionality in a custom global class and i am trying to access it .

when i double click it , it is actually going into the method of the global class , but it is not able to identify the grid. the reason for identifying the grid , i have defined two grids and each grid has different functionality .

Please suggest.

Thanks,

Ry

0 Kudos

Hello Again

Assing 1 object to 1 grid and other object to the other grid. I thin k that will work properly. Do it a Nared suggested.

Bye

Gabriel P.-

Edited by: Gabriel P.- on Oct 10, 2008 4:18 PM

Former Member
0 Kudos

Hi,

The easy solution is to create two different methods to handle the different grids..

But anyway I will check if there is a way to identify which grid is initiating the double click...

Thanks

Naren

0 Kudos

HI Naren,

thanks for your reply , can you please suggest , how to handle the same double click functionality in two different methods for two different grids in the same output .

thanks ,

Ry

Former Member
0 Kudos

Hi,

Create two objects for the same class...IN set handler you define the different method for the second grid instance.

* Objects for oo alv.
DATA:
      g_verifier         TYPE REF TO lcl_event_receiver,
      g_verifier_2       TYPE REF TO lcl_event_receiver.


* Create the object for first grid.
  CREATE OBJECT g_verifier.
  SET HANDLER g_verifier->handle_data_changed
              FOR g_grid.

* Create the object for second grid
  CREATE OBJECT g_verifier_2.
  SET HANDLER g_verifier_2->handle_data_changed_2
              FOR g_grid_2.


CLASS lcl_event_receiver DEFINITION.

  PUBLIC SECTION.

    METHODS:
      handle_data_changed
         FOR EVENT data_changed OF cl_gui_alv_grid
             IMPORTING er_data_changed.

    METHODS:
      handle_data_changed_2
         FOR EVENT data_changed OF cl_gui_alv_grid
             IMPORTING er_data_changed.

ENDCLASS.

Thanks

Naren

0 Kudos

hi Naren,

i am trying to use two different methods, but the problem i am having now is after selection screen i am populating an internal table . and is displaying proplerly on to the output . but when i double click , the program goes into the method of the global class but the internal table is refreshed . can you please suggest , why is it so.

Regards,

Ry

Former Member
0 Kudos

Hi,

The program internal table will not be available in the global class..

For that..create a public attribute for the class..make the attribute as internal table...

and in your program...after creating the object for the global class in your program...

In the public attribute internal table...set the internal table values from your program and pass it on to the class..

Then in the class method..you can access the internal table that you displayed in the program..

Hope this helps..

Thanks

Naren

0 Kudos

Hi Naren,

i tried to create an attribute lt_knb type ref to knb1 in attibutes section of the global class.

then in the program i tried to assign using create object exporting lt_knb = gt_knb .

but when i tried to activate it says lt_knb is not defined.

suggest please where i am missing .

Regards,

Ry