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 standard button Click event tracing in OOP

pkb
Participant
0 Kudos
7,238

Dear all,

I need a help for the following problem.

I am developing one program where I have used CL_GUI_aLV_GRID for editable ALV . Now I want to write code against standard toolbar button click. For example If user click on + button ( Insert row) , then I have to track that user have clicked the Insert Row button from satndard toolbar . Like that I want to track other button clicked by user through there attribute value in HANDLE_TOOLBAR method.

I am new in OOP programing in ABAP . Please help.

-pk

7 REPLIES 7
Read only

Abhijit74
Active Contributor
0 Kudos
2,196

Hello,


Do it like below.

CLASS gcl_event_receiver DEFINITION.

  PUBLIC SECTION.

    METHODS:

     handle_before_user_command FOR EVENT before_user_command of cl_gui_alv_grid

                        IMPORTING e_ucomm.

ENDCLASS.                    "lcl_event_receiver DEFINITION

CLASS gcl_event_receiver IMPLEMENTATION.

  METHOD handle_before_user_command.

    perform f_handle_before_user_command using e_ucomm.

   endmethod.

ENDCLASS. 

*&---------------------------------------------------------------------*

*&      Form  F_HANDLE_BEFORE_USER_COMMAND

*&---------------------------------------------------------------------*

*       text

*----------------------------------------------------------------------*

*      -->P_E_UCOMM  text

*----------------------------------------------------------------------*

FORM f_handle_before_user_command  USING i_ucomm TYPE syucomm.

  CASE i_ucomm.

    WHEN '&REFRESH'.

        -------

     WHEN '&OTHERS'.

     -----------------

 

Endcase.

  PERFORM f_sub_item_data.

EndForm.

Thanks,

Abhijit

Read only

pkb
Participant
0 Kudos
2,196

Dear Abhijit,

Thank you for your reply, I have done as you have suggested. But I am able to trace only SUM button click , but when Click on Append Row or Delete Row , the E_COMM not able to get their corresponding attribute value. My standard toolbar having three buttons namely Append row, Delete Row and Sum(Sigma) button . Other standard buttons are excluded from toolbar.

-pk

Read only

Abhijit74
Active Contributor
0 Kudos
2,196

Hello,

Try to get the Append row or Delete row button code on of class cl_gui_alv_grid for Associated type =  UI_FUNC.

Thanks,

Abhijit

Read only

dhanikpi
Discoverer
0 Kudos
2,196

Hi,

for functionality on standard toolbar following is the procedure.

class test definition.

Methods:

user_command FOR EVENT user_command
OF cl_gui_alv_grid
IMPORTING e_ucomm,

standard_toolbar FOR EVENT toolbar
OF cl_gui_alv_grid
IMPORTING e_object e_interactive.

endclass.

class test implementation.

METHOD user_command .
PERFORM handle_user_command USING e_ucomm .
ENDMETHOD.

METHOD standard_toolbar.

PERFORM standard_toolbar USING e_object e_interactive.

ENDMETHOD.

********THIS FORM WILL MAKE AND USER ICON (PLUS) SIMILARLY YOU CAN PUT MANY ON THE TOOLBAR********

form standard_toolbar using p_e_object  p_e_interactive.

DATA: wa_toolbar TYPE stb_button.

CLEAR ls_toolbar.

MOVE 'PLUS' to wa_toolbar-function.

MOVE ICON_SUM  to wa_toolbar-icon.

MOVE 'ADDITION' TO wa_toolbar-text

APPEND wa_toolbar TO p_e_object->mt_toolbar.

endform.

************HERE YOU CAN PUT YOUR LOGIC FOR ADDITION ETC.

form user_command USING OK_CODE TYPE sy-ucomm. "p_e_ucomm
CASE OK_CODE.

"WHEN 'PLUS'.
PERFORM PLUS.
ENDCASE .
ENDFORM.

Read only

0 Kudos
2,196

Dear Piyush,

Thank you for your reply . I have gone through your solution but it is about the custom toolbar . I want to capture the standard tool bar action .

-PK

Read only

Former Member
0 Kudos
2,196

Hi,

There is an event called 'TOOLBAR' in the events tab of cl_gui_alv_grid. In this event, one of the parameters is E_OBJECT of type CL_ALV_TOOLBAR_SET which is a class. This class has attribute MT_TOOLBAR of type TTB_BUTTON which is a line type containing the necessary fields for capturing the actions performed by user on standard tool bar. Using this you can capture the actions performed by user on the Standard Tool B

Please let me know if this does not solve.

Thank you.

Regards,

Felix Johnson

Read only

Clemenss
Active Contributor
0 Kudos
2,196

Hi pkpk,

the insert/delete row buttons trigger the data_changed event.

See my answer

OO ALV Toolbar Event

Check the coding hints and don' miss the register_edit_event.

Regards

Clemens