2013 Apr 26 6:50 AM
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
2013 Apr 26 7:55 AM
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
2013 Apr 26 9:03 AM
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
2013 Apr 26 11:06 AM
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
2013 Apr 26 1:36 PM
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.
2013 Apr 29 12:20 PM
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
2013 Apr 29 1:31 PM
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
2013 Apr 29 2:09 PM
Hi pkpk,
the insert/delete row buttons trigger the data_changed event.
See my answer to Aaron Kitts on Nov 19, 2010 8:02 PM:
Check the coding hints and don' miss the register_edit_event.
Regards
Clemens