Hide ALV toolbar buttons using ALV Exclude


Sometimes, we may need to hide some ALV toolbar buttons in ALV grid Display using REUSE_ALV_GRID_DISPLAY.
The below are the steps we are going to do to hide ALV tool bar buttons.
Get Standard GUI Function Codes.
  1. Exclude ALV toolbar functions using IT_EXCLUDE exporting parameter.
  2. Get Standard GUI function codes
We can get standard GUI function codes using function module RS_CUA_GET_STATUS_FUNCTIONS bypassing standard program SAPLKKBL and status STANDARD_FULLSCREEN.
Exclude functions using IT_EXCLUDE parameter of ALV grid
Loop through the standard GUI function which we got in the previous step, and pass to exclude table.

REPORT ZALV_FUNCTIONS_HIDE.
DATA: IT_MARA TYPE TABLE OF MARA,
     WA_MARA TYPE MARA.
DATA : FUN TYPE TABLE OF RSEUL_FUN.
DATA : WA_FUN LIKE LINE OF FUN.
DATA : IT_EXCLUDE TYPE SLIS_T_EXTAB,
      WA_EXCLUDE TYPE SLIS_EXTAB.

START-OF-SELECTION.
 SELECT * FROM MARA INTO TABLE IT_MARA UP TO 50 ROWS.


 CALL FUNCTION 'RS_CUA_GET_STATUS_FUNCTIONS'
   EXPORTING
     LANGUAGE  = 'E'
     PROGRAM   = 'SAPLKKBL'
     STATUS    = 'STANDARD_FULLSCREEN'
   TABLES
     FUNCTIONS = FUN.
 IF SY-SUBRC <> 0.
* Implement suitable error handling here
 ENDIF.

*&---------------------------------------------------------------------*
*          FOR EXCLUDING STANDARD BUTTONS FROM ALV TOOLBAR
*&---------------------------------------------------------------------*
 LOOP AT FUN INTO WA_FUN. "loop through all functions
   IF WA_FUN-FCODE EQ '&F03' OR WA_FUN-FCODE EQ '&F15' OR WA_FUN-FCODE EQ '&F12'. "don`t add back, exit, stop functions

   ELSE.
     WA_EXCLUDE-FCODE = WA_FUN-FCODE. "add all remaining
     APPEND WA_EXCLUDE TO IT_EXCLUDE.
     CLEAR WA_EXCLUDE.
   ENDIF.
 ENDLOOP.

 CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
   EXPORTING
*     I_CALLBACK_PF_STATUS_SET = 'PF_STATUS'
     I_STRUCTURE_NAME = 'MARA'
     IT_EXCLUDING     = IT_EXCLUDE "exclude functions
   TABLES
     T_OUTTAB         = IT_MARA. "MARA table data
 IF SY-SUBRC <> 0.
* Implement suitable error handling here
 ENDIF.

Share this

Related Posts