Application Development 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: 

About ALV OO output

Former Member
0 Kudos

Hi all

I have a problem about ALV OO . the question is how to add my own button on the toolbar of the ALV output.

Not copy from system . I need to use OO to add the button

Thanks

Nick

3 REPLIES 3

Former Member
0 Kudos

<b>To add your own button to ALV grid toolbar, use methods 'handle_toolbar'(To add a button) and 'handle_user_command'(To catch click event).

example program BCALV_GRID_05</b>

**********************************

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = W_REPID

I_CALLBACK_PF_STATUS_SET = 'PF_STATUS'

I_CALLBACK_USER_COMMAND = 'USER_COMMAND'

FORM SET_PF_STATUS

USING P_EXTAB TYPE SLIS_T_EXTAB. "#EC CALLED

  • Set the pf status for CHG BOM button

SET PF-STATUS 'STAT1' EXCLUDING P_EXTAB.

ENDFORM. "top_of_page

FORM USER_COMMAND USING P_UCOMM TYPE SY-UCOMM

P_SELFLD TYPE SLIS_SELFIELD.

case p_ucomm.

when '<FCODE for your button'.

  • do somethind

endcase.

ENDFORM.

YOu must create the pf status STAT1 in se41 by copying a pf status STANDARD of the program saplkkbl and adding an extra button to the copied pf status.

***********************

Regards

Vasu

Former Member
0 Kudos

Create workarea gw_toolbar TYPE stb_button.

In the Handle toolbar event of the class cl_gui_alv_grid,

MOVE gc_functioncode TO gw_toolbar-function.

MOVE text-001 TO gw_toolbar-quickinfo.

MOVE text-002 TO gw_toolbar-text.

APPEND gw_toolbar TO lp_e_object->mt_toolbar.

Then In the Handle_user_command event of the class,

CASE lp_e_ucomm.

WHEN gc_functioncode.

  • Mention how u r going to handle, when the user presses the new button created.

ENDCASE.

Reward if helpful!

Regards,

Kalpana

hymavathi_oruganti
Active Contributor
0 Kudos

CLASS LCL_EVENT_RECEIVER DEFINITION.

public section.

METHODS:

HANDLE_TOOLBAR

FOR EVENT TOOLBAR OF CL_GUI_ALV_GRID

IMPORTING E_OBJECT.

ENDCLASS. "cl_event_receiver DEFINITION

[

----


  • CLASS LCL_EVENT_RECEIVER IMPLEMENTATION

----


*

----


CLASS LCL_EVENT_RECEIVER IMPLEMENTATION.

METHOD HANDLE_TOOLBAR.

PERFORM HANDLE_TOOL_BAR USING E_OBJECT.

ENDMETHOD. "HANDLE_TOOLBAR

ENDCLASS. "LCL_EVENT_RECEIVER IMPLEMENTATION

<b>SET HANDLER EVENT_RECEIVER->HANDLE_TOOLBAR FOR GO_GRID</b>.

&----


*& Form HANDLE_TOOL_BAR

&----


  • text

----


  • -->P_E_OBJECT text

----


FORM HANDLE_TOOL_BAR USING I_OBJECT

TYPE REF TO CL_ALV_EVENT_TOOLBAR_SET.

LS_TOOLBAR-FUNCTION = 'DELE'.

LS_TOOLBAR-ICON = ICON_DELETE.

LS_TOOLBAR-TEXT = 'DELETE'.

LS_TOOLBAR-BUTN_TYPE = 0.

APPEND ls_toolbar TO I_object->mt_toolbar.

ENDFORM. " HANDLE_TOOL_BAR