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: 

How to Capture the Standard Tool bar buttons in ALV

Former Member
0 Kudos

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

4 REPLIES 4

Former Member
0 Kudos

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

nabheetscn
Active Contributor
0 Kudos

Please check SAP sample program BCALV_EDIT_01 for the same. It uses both buttons

Nabheet

Former Member
0 Kudos

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

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