Skip to Content
avatar image
Former Member

Button in Toolbar for CL_GUI_ALV_GRID in sub screen

Hi All,

I am trying to display data using ALV grid of type CL_GUI_ALV_GRID in a sub screen in a tab strip. I want a button on the toolbar of the grid, as I am using sub screen I can't use SET PF-STATUS statement. Below is the code which I had written for the button to display on toolbar of the grid.

DATA pasgr_alv TYPE REF TO cl_gui_alv_grid.

CLASS : toolbar_event_handler DEFINITION .


CLASS-METHODS: set_alv_tbar FOR EVENT toolbar OF cl_gui_alv_grid IMPORTING e_object e_interactive.


CLASS : toolbar_event_handler IMPLEMENTATION.

METHOD set_alv_tbar.

CLEAR alv_sbutton.

alv_sbutton-function = 'PRINT'.

alv_sbutton-icon = ''.

alv_sbutton-quickinfo = 'FUNCTION 1'.

alv_sbutton-butn_type = 0.

alv_sbutton-text = 'Print'.

*APPEND alv_sbutton to alv_button.

APPEND alv_sbutton TO e_object->mt_toolbar.

ENDMETHOD. "set_alv_tbar

ENDCLASS. "toolbar_event_handler IMPLEMENTATION

SET HANDLER toolbar_event_handler=>set_alv_tbar FOR pasgr_alv.

Here I am facing a problem. At first I not getting button. But when I perform any openartion on the content displayed in the grid (like sorting a column) then the button is displayed.

But I want this button to be displayed in the first display of the ALV grid. I tried by using set_registered_events of the cl_gui_alv_grid but I couldn't get exact eventid.

Is there any way to do this?



Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • avatar image
    Former Member
    Feb 02, 2012 at 01:08 PM

    I use statements, like:

    set handler event_receiver->handle_toolbar for grid.


    • Make the new functions visible.

    call method grid->set_toolbar_interactive.

    Handle_toolbar method adds the function buttons to the GUI status in the position (index) I want.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Feb 03, 2012 at 05:54 AM

    Hi Team,

    I solved my issue by calling set_toolbar_interactive of CL_GUI_ALV_GRID.

    Add comment
    10|10000 characters needed characters exceeded