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: 

Event delayed_callback - ALV GRID

MariaJoãoRocha
Contributor
0 Kudos

Hi,

I have alv grid with several functionalities (double click, user command, etc.)

Now I pretend to use the event delayed_callback of the cl_gui_alv_grid.

I’ve seen the example BCALV_TEST_GRID_EVENTS, and implement the event in my program, but it doesn’t work.

The event is not raised! Can you please help?

This is my code:

....

class cl_event_receiver_300 definition.

public section.

data: ucomm type sy-ucomm.

data: selfield type slis_selfield.

  • delayed callback

methods handle_delayed_callback

for event delayed_callback of cl_gui_alv_grid.

...

endclass.

class cl_event_receiver_300 implementation.

  • handle delayed_callback

method handle_delayed_callback.

message i000(zm) with 'Delayed'.

endmethod. "delayed_callback

Endclass.

module alv_300_display output.

if g_custom_container_300 is initial.

  • create container for ALV grid

create object g_custom_container_300

exporting

container_name = 'CUSTOM_CONTROL_300'.

endif.

if grid_300 is initial.

  • create Event Receiver

create object event_receiver_300.

  • create ALV grid

create object grid_300

exporting

i_appl_events ' ' "selected

i_parent = g_custom_container_300.

  • opt. col. width

clear gs_layout_alv.

gs_layout_alv-cwidth_opt = selected.

gs_layout_alv-grid_title = 'Contactos com o Cliente'.

gs_layout_alv-zebra = 'X'.

gs_layout_alv-sel_mode = 'A'.

  • exclusão dos botões standard da barra de ferramentas

append cl_gui_alv_grid=>mc_fc_graph to gt_funcoes_300.

append cl_gui_alv_grid=>mc_fc_help to gt_funcoes_300.

append cl_gui_alv_grid=>mc_mb_sum to gt_funcoes_300.

append cl_gui_alv_grid=>mc_fc_average to gt_funcoes_300.

append cl_gui_alv_grid=>mc_fc_view_crystal to gt_funcoes_300.

append cl_gui_alv_grid=>mc_fc_info to gt_funcoes_300.

  • handle for D'n'D

  • gs_layout_alv-s_dragdrop-row_ddid = g_handle_alv.

  • handler for ALV grid

set handler event_receiver_300->handle_toolbar_set for grid_300.

set handler event_receiver_300->handle_user_command for grid_300.

set handler event_receiver_300->handle_double_click for grid_300.

set handler event_receiver_300->handle_delayed_callback

for grid_300.

call method grid_300->register_delayed_event

exporting

i_event_id = cl_gui_alv_grid=>mc_evt_delayed_move_curr_cell.

  • criação do catálogo de campos

perform create_fieldcat_cont.

  • variante

variant_alv-report = sy-repid.

call method grid_300->set_table_for_first_display

exporting i_save = 'A'

it_toolbar_excluding = gt_funcoes_300[]

i_default = 'X'

i_buffer_active = ' '

i_bypassing_buffer = ' '

i_consistency_check = ' '

changing it_outtab = it_contactos[]

it_fieldcatalog = gt_fieldcat_cont[].

  • flush

call method cl_gui_control=>set_focus exporting control = grid_300.

call method cl_gui_cfw=>flush.

endif.

if flg_new_300 = selected.

clear flg_new_300.

  • call with data

call method grid_300->set_frontend_layout

exporting is_layout = gs_layout_alv.

call method grid_300->refresh_table_display.

  • flush

call method cl_gui_control=>set_focus exporting control = grid_300.

call method cl_gui_cfw=>flush.

endif.

endmodule. " alv_300_display OUTPUT

Best Regards

1 ACCEPTED SOLUTION

bryan_sippel3
Explorer
0 Kudos

In case you are still looking for a possible solution (after 13 years),
or more likely, if anyone else might be... (I was)

If you don't need to use the right-click context menu in your ALV grid, you can repurpose the CONTEXT_MENU_REQUEST event...

CLASS lcl_event_receiver DEFINITION.
  PUBLIC SECTION.
    METHODS:
      handle_context_menu 
        FOR EVENT context_menu_request OF cl_gui_alv_grid 
          IMPORTING e_object.
ENDCLASS.

CLASS lcl_event_receiver IMPLEMENTATION.
  METHOD handle_context_menu.
*   turn off the context menu options
    CALL METHOD e_object->clear.
*   handle your particular right-click functionality
    PERFORM handle_context_menu USING e_object.
  ENDMETHOD.
ENDCLASS.
FORM create_grid.
* create and initialize the grid when your program starts
  CREATE OBJECT gw_grid
    EXPORTING
      i_parent      = gw_container
      i_appl_events = 'X'.
  CALL METHOD gw_grid->set_table_for_first_display
    ...
* set the context menu handler
  SET HANDLER gw_alv_event->handle_context_menu FOR gw_grid.
ENDFORM. "create_grid
FORM handle_context_menu USING e_object TYPE REF TO cl_ctmenu.
  DATA:
    lt_row_no TYPE lvc_t_roid,
    lw_row    TYPE i,
    lw_value  TYPE c,
    lw_col    TYPE i,
    lw_row_id TYPE lvc_s_row,
    lw_col_id TYPE lvc_s_col,
    lw_row_no TYPE lvc_s_roid.
  FIELD-SYMBOLS:
    <lf_data> LIKE LINE OF gw_data. "pointer to your data table
* get the current cursor row
  CALL METHOD gw_grid_sppr->get_current_cell
    IMPORTING
      e_row     = lw_row
      e_value   = lw_value
      e_col     = lw_col
      es_row_id = lw_row_id
      es_col_id = lw_col_id
      es_row_no = lw_row_no.
  CHECK lw_row_no-row_id IS NOT INITIAL.
* read your associated data
  READ TABLE gt_data ASSIGNING <lf_data> INDEX lw_row_no-row_id.
  CHECK sy-subrc EQ 0.
* do your stuff...
  CALL METHOD cl_gui_cfw=>flush.
ENDFORM. "handle_context_menu

Hope that helps. 😄

8 REPLIES 8

Former Member
0 Kudos

Maria,

I am not sure in your case, why are you handling the DELAYED_CALLBACK EVENT rather than the events for which you have set the handles

set handler event_receiver_300->handle_toolbar_set for grid_300.

set handler event_receiver_300->handle_user_command for grid_300.

set handler event_receiver_300->handle_double_click for grid_300.

You should write methods for HANDLE_TOOLBAR, HANDLE_USER_COMMAND and HANDLE_DOUBLE_CLICK. I couldn't find the code for the same.

Regards,

Ravi

Note : Please mark the helpful answers.

MariaJoãoRocha
Contributor
0 Kudos

Hi,

I'm already using the handles:

handle_toolbar_set for grid_300

handle_user_command for grid_300

handle_double_click for grid_300

I pretend to use the delayed_callback to show a text on the screen at same time the user clicks a cell other than that currently selected.

Best regards,

Maria João Rocha

0 Kudos

Hello Maria,

As per the <a href="http://help.sap.com/saphelp_erp2004/helpdata/en/ee/c8e065d52611d2b468006094192fe3/frameset.htm">documentation</a> the event gets triggerred with <i>a delay</i>. that could have been the reason.

Also, shouldn't you actually be using the event <b>delayed_changed_sel_callback</b> for your purpose ?

Regards,

Anand Mandalika.

MariaJoãoRocha
Contributor
0 Kudos

Hi,

The delay..., weel the example program BCALV_TEST_GRID_EVENTS, works fine and the documentation says "short delay of 1,5 seconds".

Perhaps is there other way of doing what I need, but I don't know how! Can you help?

Best Regards,

Maria João Rocha

0 Kudos

Maria,

I am not sure what exactly is the reason of using the DELAY CALL BACK. The events you have mentioned can used directly by activating them.

Can you try removing the DELAYED CALL BACK event and see if you get the desired output?

Regards,

Ravi

MariaJoãoRocha
Contributor
0 Kudos

Hi,

I get the desired output with a command button, for instance - that's easy.

Maybe I will give up this solution!

(Sincerely I'd like to make it work!!)

Regards,

Maria João Rocha

bryan_sippel3
Explorer
0 Kudos

In case you are still looking for a possible solution (after 13 years),
or more likely, if anyone else might be... (I was)

If you don't need to use the right-click context menu in your ALV grid, you can repurpose the CONTEXT_MENU_REQUEST event...

CLASS lcl_event_receiver DEFINITION.
  PUBLIC SECTION.
    METHODS:
      handle_context_menu 
        FOR EVENT context_menu_request OF cl_gui_alv_grid 
          IMPORTING e_object.
ENDCLASS.

CLASS lcl_event_receiver IMPLEMENTATION.
  METHOD handle_context_menu.
*   turn off the context menu options
    CALL METHOD e_object->clear.
*   handle your particular right-click functionality
    PERFORM handle_context_menu USING e_object.
  ENDMETHOD.
ENDCLASS.
FORM create_grid.
* create and initialize the grid when your program starts
  CREATE OBJECT gw_grid
    EXPORTING
      i_parent      = gw_container
      i_appl_events = 'X'.
  CALL METHOD gw_grid->set_table_for_first_display
    ...
* set the context menu handler
  SET HANDLER gw_alv_event->handle_context_menu FOR gw_grid.
ENDFORM. "create_grid
FORM handle_context_menu USING e_object TYPE REF TO cl_ctmenu.
  DATA:
    lt_row_no TYPE lvc_t_roid,
    lw_row    TYPE i,
    lw_value  TYPE c,
    lw_col    TYPE i,
    lw_row_id TYPE lvc_s_row,
    lw_col_id TYPE lvc_s_col,
    lw_row_no TYPE lvc_s_roid.
  FIELD-SYMBOLS:
    <lf_data> LIKE LINE OF gw_data. "pointer to your data table
* get the current cursor row
  CALL METHOD gw_grid_sppr->get_current_cell
    IMPORTING
      e_row     = lw_row
      e_value   = lw_value
      e_col     = lw_col
      es_row_id = lw_row_id
      es_col_id = lw_col_id
      es_row_no = lw_row_no.
  CHECK lw_row_no-row_id IS NOT INITIAL.
* read your associated data
  READ TABLE gt_data ASSIGNING <lf_data> INDEX lw_row_no-row_id.
  CHECK sy-subrc EQ 0.
* do your stuff...
  CALL METHOD cl_gui_cfw=>flush.
ENDFORM. "handle_context_menu

Hope that helps. 😄

0 Kudos

Hi Bryan Sippel,

Thanks a lot for your reply. The issue has been resolved.

For now I have another task 🙂 🙂 .

Regards,