01-28-2014 6:55 AM
Hi ,
I need to add custom code when user click on insert or delete buttons from standard tool bar in ALV
it requires two events : toolbar and user_command / before_user_command .
I am not getting the desired output . Could you help me in this or provide me test code .
Thanks ,
Mayank
01-28-2014 7:05 AM
Hi,
Write handler class for handling events of ALV_GRID refer below code for more details
class lcl_event_receiver definition.
public section.
methods handle_after_user_command
for event after_user_command of cl_gui_alv_grid
importing e_ucomm.
private section.
endclass.
class lcl_event_receiver implementation.
method handle_after_user_command.
case e_ucomm.
when '&COL_INV'.
w_gblflag = 'Y'.
ucomm = e_ucomm.
when '&SORT_ASC'.
w_gblflag = 'Y'.
ucomm = e_ucomm.
when '&SORT_DSC'.
w_gblflag = 'Y'.
ucomm = e_ucomm.
when '&SUBTOT'.
w_gblflag = 'Y'.
ucomm = e_ucomm.
when '&FILTER' or '&DELETE_FILTER'.
w_gblflag = 'Y'.
ucomm = e_ucomm.
when '&SUMC'.
w_gblflag = 'Y'.
ucomm = e_ucomm.
when '&COL0'.
w_gblflag = 'Y'.
ucomm = e_ucomm.
when '&PC'.
w_gblflag = 'Y'.
ucomm = e_ucomm.
when '&LOAD'.
w_gblflag = 'Y'.
ucomm = e_ucomm.
* perform clear_fr_to.
when '&OAD'.
w_gblflag = 'Y'.
ucomm = e_ucomm.
when '&AVE'.
w_gblflag = 'Y'.
ucomm = e_ucomm.
when '&SAVE'.
w_gblflag = 'Y'.
ucomm = e_ucomm.
when '&OL0'.
w_gblflag = 'Y'.
ucomm = e_ucomm.
when 'DTC_CONT'.
w_gblflag = 'Y'.
ucomm = e_ucomm.
when 'YES' or 'NO' or 'OK' or 'CANC'.
w_gblflag = 'Y'.
ucomm = e_ucomm.
when others.
w_gblflag = 'N'.
endcase.
endmethod. "handle_after_user_command
endclass. "lcl_event_receiver IMPLEMENTATION
data: gr_events type ref to lcl_event_receiver.
data : ls_sel_hide type slis_sel_hide_alv.
data ref1 type ref to cl_gui_alv_grid.
call function 'GET_GLOBALS_FROM_SLVC_FULLSCR'
importing
es_sel_hide = ls_sel_hide
e_grid = ref1.
create object gr_events.
set handler gr_events->handle_after_user_command for ref1.
Regards,
Praveen Savanth N
01-28-2014 7:27 AM
Please check SAP sample program BCALV_EDIT_01 for the same. It uses both buttons
Nabheet
01-28-2014 8:52 AM
Still m not getting the desired output .. I doesn't work for insert and delete option . could you tell me which events i have to use to get the correct output .
Thanks
Mayank
01-28-2014 8:55 AM
Mayank
Did you check BCALV_EDIT_04 and others BCALV*EDIT* programs. In 04 program the complete detail of how to add/delete button control is already done. Please refer that
Nabheet