2010 Mar 10 6:45 AM
Hello Experts,
Is there a way that my data_changed event gets triggered even if if the user justs
input a value and not pressing enter?
Also, when I add or delete rows in my al grid, how do I also trigger the said event?
Hope you can help me guys. Thank you and take care!
2010 Mar 10 9:21 AM
call the method CL_GUI_ALV_GRID -> CHECK_CHANGED_DATA . this method does Verification of Changes and Triggers Event DATA_CHANGED
u can check in debugg mode. the above method will trigger DATA_CHANGED event. so write your logic wat ever u need to perform inside the method of the event DATA_CHANGED
sample code
call this below method in ur PAI of ur screen.
CALL METHOD CL_GUI_ALV_GRID->check_changed_data
IMPORTING
e_valid = w_valid.
also you need to register the events in PBO of ur screen.I hope u have done as
CALL METHOD CL_GUI_ALV_GRID->register_edit_event
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_modified.
CALL METHOD CL_GUI_ALV_GRID->register_edit_event
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_enter.
Instantiate the event or it won't work.
CREATE OBJECT w_event_receiver.
SET HANDLER w_event_receiver->handle_data_changed FOR w_alvgd2.
and the method will be declared in global section of the program as
CLASS lcl_grid_event_receiver DEFINITION.
PUBLIC SECTION.
METHODS: handle_data_changed
FOR EVENT data_changed OF cl_gui_alv_grid
IMPORTING er_data_changed,
endclass.
CLASS lcl_grid_event_receiver IMPLEMENTATION.
METHOD handle_data_changed.
*event is ttriggered when data is changed in the output
PERFORM check_data USING er_data_changed
t_data.
ENDMETHOD.
endclass.
inside routine Check_data, u have to write ur logic
Its works for me. please check
thanks
sangeetha
2010 Mar 10 7:00 AM
If you're talking about classical ABAP dynpro's there's no way any event is fired unless user presses enter, uses some function key, etc. This is actually a feature, because you want to minimize the number of roundtrips between the application server and the presentation server. So the user has to explicitly do something (apart from just entering data) to fire the PAI/PBO processing sequence...
Cannot comment on your ALV question, because I don't understand it...
2010 Mar 10 7:07 AM
Hi Harald,
Ok then point noted. But in my ALV, I registered 'ENTER' event to trigger event data_changed of my ALV but it is not working. Hvae you encountered this issue before?
2010 Mar 10 8:09 AM
"activate data_changed
CALL METHOD g_alv_grid_ref->register_edit_event
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_enter "trigger event after ENTER is pressed
* i_event_id = cl_gui_alv_grid=>MC_EVT_MODIFIED "or trigger once you go to next cell after modification (without pressing ENTER)
EXCEPTIONS
error = 1
OTHERS = 2.
"also set the handler for the event
set handler g_alv_event_ref->handle_data_changed FOR g_alv_grid_ref,
Regards
Marcin
2010 Mar 10 8:22 AM
Hi Marcin,
That is exactly what my code is. But I am wondering that if I press enter, it does not trigger. It only trigger after I press F4 on a certain field.
2010 Mar 10 8:30 AM
Can you share your code then, together will the handler implementation? This is working fine for me.
2010 Mar 10 8:38 AM
Haven't used the Enter event yet. I'd expect the event handling should work, does your handler not get triggered at all? When debugging, do you see anything happening on enter? Maybe you can post some more details which ALV you're using and what you did (e.g. is it CL_GUI_ALV_GRID with EVT_ENTER?)
Edited by: Harald Boeing on Mar 10, 2010 12:42 AM
Sorry - my internet connection is too slow and I didn't recheck for more recent posts before I posted my answer...
2010 Mar 10 8:54 AM
Small addition to my previous claim that you have to hit Enter to trigger PAI/PBO. This is of course only true for simple text input fields. For checkboxes, radiobutton or fields with value lists you can define attach a function code to the field and thus trigger the PAI/PBO processing...
2016 Oct 05 10:05 AM
Hi Aris,
I Have the same problem. Did you find the answer?
Regards,
Gayatri
2010 Mar 10 9:21 AM
call the method CL_GUI_ALV_GRID -> CHECK_CHANGED_DATA . this method does Verification of Changes and Triggers Event DATA_CHANGED
u can check in debugg mode. the above method will trigger DATA_CHANGED event. so write your logic wat ever u need to perform inside the method of the event DATA_CHANGED
sample code
call this below method in ur PAI of ur screen.
CALL METHOD CL_GUI_ALV_GRID->check_changed_data
IMPORTING
e_valid = w_valid.
also you need to register the events in PBO of ur screen.I hope u have done as
CALL METHOD CL_GUI_ALV_GRID->register_edit_event
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_modified.
CALL METHOD CL_GUI_ALV_GRID->register_edit_event
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_enter.
Instantiate the event or it won't work.
CREATE OBJECT w_event_receiver.
SET HANDLER w_event_receiver->handle_data_changed FOR w_alvgd2.
and the method will be declared in global section of the program as
CLASS lcl_grid_event_receiver DEFINITION.
PUBLIC SECTION.
METHODS: handle_data_changed
FOR EVENT data_changed OF cl_gui_alv_grid
IMPORTING er_data_changed,
endclass.
CLASS lcl_grid_event_receiver IMPLEMENTATION.
METHOD handle_data_changed.
*event is ttriggered when data is changed in the output
PERFORM check_data USING er_data_changed
t_data.
ENDMETHOD.
endclass.
inside routine Check_data, u have to write ur logic
Its works for me. please check
thanks
sangeetha
2015 Nov 04 12:47 PM
Hi Sangeeta,
I am having the same requirement and it worked for me partially.
When i am selecting the checkbox(changing the data on output screen), it is triggering the next screen. But it should not happen. It has to trigger the next screen when i am completed selecting the changed(not after selecting each and every record).
So can please suggest any solution to handle the situation.
Thanks in Advance,
Regards,
Harinath N
2016 Jun 24 9:12 AM
Hi Sangeetha ,
yepp - that's the solution!
I could solve my Problem too with CL_GUI_ALV_GRID->check_changed_data
Thank you.
Regards,
Markus