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: 

Interactive ALV - Code Advice needed for displaying ALV in ALV

mrkarthi
Participant
0 Kudos

hello all..

i used the following code for creating the screen and displayed the first ALV output.


CL_GUI_CUSTOM_CONTAINER=>SCREEN0.

When i have to display the details based on the mouse double click, i added the event handler class definition and implementation.

i need some code advice of how to define and handle the event in the above scenario.

Regards,

Karthi M R.

1 ACCEPTED SOLUTION

MarcinPciak
Active Contributor
0 Kudos

I am curious if you ever called your empty screen? This should go like


CLASS lcl_event_handler DEFINITION.
  PUBLIC SECTION.
    METHODS handle_double_click FOR EVENT double_click OF
  cl_gui_alv_grid IMPORTING e_row.
ENDCLASS.                    

CLASS lcl_event_handler IMPLEMENTATION.
  METHOD: handle_double_click.
    MESSAGE 'I am double click ALV handler' TYPE 'I'.
  ENDMETHOD.              
ENDCLASS.                

START-OF-SELECTION.
  DATA r_grid TYPE REF TO cl_gui_alv_grid.
  DATA it_sflight TYPE TABLE OF sflight.
  DATA r_event_handler TYPE REF TO lcl_event_handler.

  SELECT * FROM sflight INTO TABLE it_sflight UP TO 10 ROWS.

  CREATE OBJECT r_grid
    EXPORTING
      i_parent = cl_gui_custom_container=>screen0.

  CREATE OBJECT r_event_handler.

  CALL METHOD r_grid->set_table_for_first_display
    EXPORTING
      i_structure_name = 'SFLIGHT'
    CHANGING
      it_outtab        = it_sflight.

  SET HANDLER r_event_handler->handle_double_click FOR r_grid.

  CALL SCREEN 100.

Regards

Marcin

9 REPLIES 9

Former Member
0 Kudos

Could you elaborate your requirement more as to what you are trying to achieve? There are lot of demo program for ALV, please check out the programs in 'SLIS' package class...

0 Kudos

@ Mr. Kris


CLASS lcl_event_handler DEFINITION.
  PUBLIC SECTION.
    METHODS handle_double_click FOR EVENT double_click OF
  cl_gui_alv_grid IMPORTING e_row.
ENDCLASS. 

CLASS lcl_event_handler IMPLEMENTATION.
  METHOD: handle_double_click.
*    READ TABLE dgmst_order INDEX e-row-index INTO dgw_order.
    MESSAGE i001.
*   Double Click is executed. Now this is used to confirm the execution
  ENDMETHOD.
ENDCLASS.

CREATE OBJECT r_grid
    EXPORTING
*    i_shellstyle      = 0
*    i_lifetime        =
       i_parent          = cl_gui_custom_container=>screen0.
*    i_appl_events     = space
*    i_parentdbg       =
*    i_applogparent    =
*    i_graphicsparent  =
*     i_name            =
*    i_fcat_complete   = space
*  EXCEPTIONS
*    error_cntl_create = 1
*    error_cntl_init   = 2
*    error_cntl_link   = 3
*    error_dp_create   = 4
*    others            = 5

  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

  CREATE OBJECT r_event_handler.

  CALL METHOD r_grid->set_table_for_first_display
      EXPORTING
*    i_buffer_active               =
*    i_bypassing_buffer            =
*    i_consistency_check           =
*    i_structure_name              =
*    is_variant                    =
*    i_save                        =
*    i_default                     = 'X'
       is_layout                     = dgmss_is_layout
*    is_print                      =
*    it_special_groups             =
*    it_toolbar_excluding          =
*    it_hyperlink                  =
*    it_alv_graphics               =
*    it_except_qinfo               =
*    ir_salv_adapter               =
    CHANGING
       it_outtab                     = dgmst_order
       it_fieldcatalog               = dgmst_it_fieldcatalog
       it_sort                       = dgmst_it_sort
*    it_filter                     =
*  EXCEPTIONS
*    invalid_parameter_combination = 1
*    program_error                 = 2
*    too_many_lines                = 3
*    others                        = 4
          .
  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

    SET HANDLER r_event_handler->handle_double_click FOR r_grid.

  ENDIF.

will this code work for user double click? any modifications should be done?

Please advice me on this regard.

any additional code to be added for getting interactive alv? please advice.

Edited by: Karthi M R on Feb 11, 2011 7:19 PM

0 Kudos

It looks like it might work. Have you tried running this code?

0 Kudos

@ Mr. Erik.

Till the first ALV it works fine.

i couldn't get the expected msg window for the double click event.



MESSAGE i001.

Regards,

Karthi M R.

0 Kudos

Guess the problem is with the events handling & triggering.

Please guide.

Regards,

Karthi M R.

0 Kudos

Hi Karthi,

You have not implemented the below method completely, so you are getting message i1001 as written on double clicking..

CLASS lcl_event_handler IMPLEMENTATION.
  METHOD: handle_double_click.
*    READ TABLE dgmst_order INDEX e-row-index INTO dgw_order.
    MESSAGE i001.
*   Double Click is executed. Now this is used to confirm the execution
  ENDMETHOD.
ENDCLASS.

Please do like this and call other screen or your relevant processing.

 READ TABLE int_output INTO ws_output INDEX is_row_no-row_id .
  IF sy-subrc = 0 .
    CALL SCREEN 200 . 
  ENDIF .

Hope this helps.

MarcinPciak
Active Contributor
0 Kudos

I am curious if you ever called your empty screen? This should go like


CLASS lcl_event_handler DEFINITION.
  PUBLIC SECTION.
    METHODS handle_double_click FOR EVENT double_click OF
  cl_gui_alv_grid IMPORTING e_row.
ENDCLASS.                    

CLASS lcl_event_handler IMPLEMENTATION.
  METHOD: handle_double_click.
    MESSAGE 'I am double click ALV handler' TYPE 'I'.
  ENDMETHOD.              
ENDCLASS.                

START-OF-SELECTION.
  DATA r_grid TYPE REF TO cl_gui_alv_grid.
  DATA it_sflight TYPE TABLE OF sflight.
  DATA r_event_handler TYPE REF TO lcl_event_handler.

  SELECT * FROM sflight INTO TABLE it_sflight UP TO 10 ROWS.

  CREATE OBJECT r_grid
    EXPORTING
      i_parent = cl_gui_custom_container=>screen0.

  CREATE OBJECT r_event_handler.

  CALL METHOD r_grid->set_table_for_first_display
    EXPORTING
      i_structure_name = 'SFLIGHT'
    CHANGING
      it_outtab        = it_sflight.

  SET HANDLER r_event_handler->handle_double_click FOR r_grid.

  CALL SCREEN 100.

Regards

Marcin

0 Kudos

Thanks for the reply Mr.Marcin.

I made mistakes in the declaration part.

i could able to handle it proper now.

Regards,

Karthi M R.

0 Kudos

Glad that I could help. See, much better posting here;)

If still any doubts just let us know.

Regards

Marcin