10-16-2011 5:50 AM
Hi ,
I wanna add a pushbutton to my ALV report toolbar, I have tried by screen painter(se51) but its not working. That is when you open the screen painter its showing the push button, but when you run the screen as transaction its not showing that button.
Any help is greatly appreciated.
Regards
Moderator Message: Please search before posting your question. Thread locked.
Edited by: Suhas Saha on Oct 18, 2011 3:40 PM
10-16-2011 10:03 AM
Hi,
You can use Event USER_COMMAND of class cl_gui_alv_grid.
For example, below given code for DELETE button in ALV tool bar.
CLASS lcl_event_handler DEFINITION.
PUBLIC SECTION.
METHODS:
user_command
FOR EVENT user_command OF cl_gui_alv_grid
IMPORTING e_ucomm.
ENDCLASS. "LCL_EVENT_HANDLER DEFINITION
*----------------------------------------------------------------------*
* CLASS LCL_EVENT_HANDLER IMPLEMENTATION
*----------------------------------------------------------------------*
* Class Implementation for changed data in grid
*----------------------------------------------------------------------*
CLASS lcl_event_handler IMPLEMENTATION.
METHOD handle_toolbar.
DATA: ls_toolbar TYPE stb_button.
CLEAR ls_toolbar.
MOVE 'DELETE' TO ls_toolbar-function.
MOVE icon_delete_row TO ls_toolbar-icon.
MOVE 'Deletes the current record' TO ls_toolbar-quickinfo.
MOVE 'Delete' TO ls_toolbar-text.
MOVE ' ' TO ls_toolbar-disabled.
APPEND ls_toolbar TO e_object->mt_toolbar.
CLEAR ls_toolbar.
ENDMETHOD.
ENDCLASS.
Regards,
Rajesh
10-18-2011 11:00 AM
Hi Harsh,
To add button in the ALV toolbar, follow the below steps :
1. Open Functional group SALV in se80 and copy the GUI status 'STANDARD' in customer namespace ( for e.g. ZSTANDARD' to your ALV report program.
2. Once you copy the GUI status, open your ALV report program in se80 and modify it's GUI status 'ZSTANDARD' according to your requirement.
3. Code accordingly in your ALV report program.
Here is the below code for your reference.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = g_repid
i_callback_pf_status_set = alv_status_set
i_callback_user_command = *alv_user_comm*
i_grid_title = grid_title
i_save = g_save
is_variant = gs_variant
is_layout = alv_layout
it_fieldcat = alv_fieldcat[]
it_events = gt_events[]
it_sort = alv_sort[]
IMPORTING
e_exit_caused_by_caller = g_exit_caused_by_caller
es_exit_caused_by_user = gs_exit_caused_by_user
TABLES
t_outtab = it_final[].
PERFORM *alv_user_comm* USING r_ucomm
rs_selfield.
FORM *alv_user_comm* USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
r_ucomm = sy-ucomm.
CASE r_ucomm.
ENDCASE.
ENDFORM.
Let us know if you still having some issues.
Cheers
VJ