Application Development and Automation 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: 
Read only

ALV Grid Event Problem

Former Member
0 Likes
736

Hi,

I have a dialog that contains an ALV grid and three buttons. When the ALV grid is created, it's parent is specified as a custom container.

  • Container

data : g_custom_container type ref to cl_gui_custom_container.

  • ALV Grid

data : g_grid type ref to cl_gui_alv_grid.

create object g_custom_container

exporting container_name = p_cont_name.

create object g_grid

exporting i_parent = g_custom_container

I_APPL_EVENTS = 'X'.

I would like the user to be able to just hit enter to accept the values displayed in the ALV. My problem is that when the dialog is created, the ALV has focus so the event isn't getting to the PAI of the dialog. If I click the mouse outside of the ALV to take focus away from the ALV, hitting the enter key does trigger the correct event in the dialog PAI. How can I either set the focus outside of the ALV when the dialog loads, or make the ALV forward the event to the dialog.

Thank you very much for any isight you can lend!

John Richason

5 REPLIES 5
Read only

Laxmana_Appana_
Active Contributor
0 Likes
645

Hi,

Register these events for Grid to enable 'enter'.

CALL METHOD G_GRID->REGISTER_EDIT_EVENT

EXPORTING

I_EVENT_ID = cl_gui_alv_grid=>mc_evt_modified.

CALL METHOD G_GRID->REGISTER_EDIT_EVENT

EXPORTING

I_EVENT_ID = cl_gui_alv_grid=>mc_evt_enter.

Method to set focus on a particular cell of the ALV

CL_GUI_ALV_GRID ->set_current_cell_via_id.

Regards

Appana

Read only

0 Likes
645

Hi Appana,

Thank you for your fast response. Will these enable the enter event for the ALV? How do I get the event to the screen PAI afterwards?

Thanks again,

John

Read only

0 Likes
645

Hi John, are you working with an editable ALV grid? If so, the code below will allow an event to be fired when the user hits enter after the data has been changed.

           call method alv_grid->register_edit_event
                        exporting
                           i_event_id = cl_gui_alv_grid=>mc_evt_enter.

You then need to create an event handler to handle the event being fired when the data is changed.


*   create Event Receiver
          create object event_receiver.

*   handler for ALV grid
          set handler event_receiver->handle_data_changed for alv_grid.

REgards,

Rich Heilman

Read only

0 Likes
645

In the event handler is where you will do any coding that you need to do when the user presses enter on the alv grid.

Regards,

Rich Heilman

Read only

0 Likes
645

Thank you for your suggestions. It turned out that the person who initially wrote the code was creating a second grid object without removing the first one.

Thanks again,

John