Register Login

ALV using REUSE_ALV_LIST_DISPLAY, How to Add a New Button?

Updated May 18, 2018

Add Button to ALV Toolbar with REUSE_ALV_LIST_DISPLAY

In the program which calls ALV using REUSE_ALV_LIST_DISPLAY,

I have to add a new button.

I saw the demo program BCALV_GRID_08, which is written using ABAP-Controls.

In that example, the button is added using TOOLBAR event of cl_gui_alv_grid.

Could you help me to implement the same logic using REUSE_ALV_LIST_DISPLAY parameters.

Please follow the below steps:

  • You should copy the 'STANDARD' GUI status from program SAPLKKBL using transaction SE90 -->Programming SubObjects--> Gui Status.
  • Execute this transaction to get to next screen. select status using checkbox. click on GUI Status --> Copy.
  • Enter your Z program name and the name you what for this status - you can keep it as 'STANDARD' to be simple.
  • Then you can edit the new status to add or delete buttons. This will also bring in the standard SAP ALV functionality such as sorting/subtotaling etc...
  • When you call 'REUSE_ALV_GRID_DISPLAY' make sure you pass it the new status name.

An example of one of mine:

call function 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = 'ZSDBOLST_REPORT'
i_callback_pf_status_set = 'STANDARD' <---------
i_callback_user_command = 'USER_COMMAND'
i_structure_name = 'I_BOLACT'
i_grid_title = 'BOL Action Report'(031)
is_layout = gs_layout
it_fieldcat = gt_fieldcat[]
i_save = 'A'
is_variant = v_variant
TABLES
t_outtab = i_bolact
EXCEPTIONS
program_error = 1
others = 2.

I just tried the same procedure ,but my entire application toolbar disappeared and a lock icon appears next to the application toolbar in my copied pf-status.

Could you advice what might have gone wrong ?

As identified with the FM's help you can do the following.

1). Using SE80 (I think) you can copy a GUI status from one program to another. It mentions which one in the FM's help.

2). Create a form named like so:

Code:

*****************************************************************
* Form Set_pf_status

* Notes: Called by FM REUSE_ALV_GRID_DISPLAY

*****************************************************************
FORM set_pf_status USING rt_extab TYPE slis_t_extab.

SET PF-STATUS 'ZSTANDARD'.

ENDFORM. "Set_pf_status

In the above case the GUI status copied was named ZSTANDARD and adjusted accordingly, adding and removing the desired buttons. A button was added called '%DELETE'.

3). Create the following report:

Code:

*****************************************************************
* Form User_command
* Notes: Called by FM REUSE_ALV_GRID_DISPLAY
* Detects whether the icon/button for
* 'Return Tag Deletion' has been pressed. If it has then
* detect whether any rows have been highlighted and then
* set the delete flag.

*****************************************************************
FORM user_command USING r_ucomm LIKE sy-ucomm

rs_selfield TYPE slis_selfield.

DATA: li_count TYPE I.

IF r_ucomm EQ '%DELETE'.
LOOP AT %g00 WHERE mark EQ 'X'.
ADD 1 TO li_count.
ENDLOOP.
IF li_count GT 0.
gc_delete_flag = 'X'.
r_ucomm = '&F03'. "Back arraow
ELSE.

MESSAGE W000 WITH 'Please highlight the rows to be deleted!'.
ENDIF.
ENDIF.
ENDFORM. "User_command

As I've added an extra button to indicate which records should be deleted I need to identify a form to be called to process when this button is chosen.

Then when you call the ALV function you to specify the following extra details:

Code:

call function 'REUSE_ALV_GRID_DISPLAY'
exporting i_callback_program = gc_repid
I_CALLBACK_PF_STATUS_SET = 'SET_PF_STATUS'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
i_grid_title = lc_grid_title
is_layout = lc_layout
it_fieldcat = gt_fieldcat
it_sort = sort
i_save = l_save
is_reprep_id = l_bbs_id
is_variant = l_variant
tables t_outtab = %g00
exceptions program_error = 1
others = 2.

The parameters in capitals are the extra ones that need to be added.


×