The following ALV for Fm:reuse_alv_grid_display, to add a button as an example, modifies the Oo ALV toolbar in roughly the same way.
1. Create a GUI status
First in the program to create a tool bar, generally want to be modified on the basis of the Standard toolbar, you can go to the function group Salv copy standard GUI status to their own program, if copy came to the name of 0100.
Optionally, add custom buttons, corresponding icon and function code BUTTON1, or delete buttons that are not required by some buttons to save activation.
2, when the call function Reuse_alv_grid_display, the incoming parameter I_callback_pf_status_set = ' Set_pf_status '
' Set_pf_status ' is a form of the name, can be arbitrarily written, and then add ' set_pf_status ' This form in the program, which is actually the PBO process, the code is very simple, as follows
*&--------------------------------------------------------------------*
*& Form Set_pf_status
*&--------------------------------------------------------------------*
* Text
*---------------------------------------------------------------------*
FORM set_pf_status USING rt_extab TYPE slis_t_extab.
SET pf-status ' 0100 '.
EndForm. "Set_pf_status
In fact, if in the first step, do not delete the button, and do not want to show it, you can also write the code in this form filter out, the following meaning is not to display the sort of two buttons.
*&--------------------------------------------------------------------*
*& Form Set_pf_status
*&--------------------------------------------------------------------*
* Text
*---------------------------------------------------------------------*
FORM set_pf_status USING rt_extab TYPE slis_t_extab.
Data:begin of ex_tab occurs 0,
FCode like Sy-ucomm,
END of Ex_tab.
Ex_tab-fcode = ' &odn '. APPEND Ex_tab. " Ascending
Ex_tab-fcode = ' &oup '. APPEND Ex_tab. " Descending
SET pf-status ' standard ' excluding ex_tab.
EndForm. "Set_pf_status
Note that it is necessary to pass in the parameter I_callback_program = I_repid "Otherwise, the system cannot find the ' set_pf_status ' form and cannot execute the form.
3, add a button, sure to add the button event when the call function Reuse_alv_grid_display, the incoming parameter I_callback_user_command = ' User_command '
Similarly user_command this is a form name, can be arbitrarily named, is a Pai incident response form, in the code to implement this form, can be as follows
*&--------------------------------------------------------------------*
*& Form User_command
*&--------------------------------------------------------------------*
* Text
*---------------------------------------------------------------------*
FORM User_command USING R_ucomm like Sy-ucomm
Rs_selfield TYPE Slis_selfield.
Case R_ucomm.
When ' BUTTON1 '. " BUTTON1 is the function code for that custom button.
PERFORM Frm_button1. " Perform the appropriate processing
When others.
Endcase.
EndForm. "User_command
In the ALV toolbar to add a button, and handle the example of button events, according to this idea, delete or filter out the ALV toolbar button is also done, can be directly deleted in the custom GUI status, or in Set_pf_ Staus This form uses excluding to do all the work.
Note: If you want to preserve the functionality of some standard buttons, do not modify their function codes.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Modify the ALV toolbar to add and Remove buttons on ALV toolbar