Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

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?



Former Member
Not what you were looking for? View more on this topic or Ask a question