Hide ALV toolbar buttons using ALV Exclude

HIde ALV toolbar buttons using IT_EXCLUDE, REUSE_ALV_GRID_DISPLAY hide ALV toolbar buttons

+ -

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.

  1. Get Standard GUI Function Codes.
  2. Exclude ALV toolbar functions using IT_EXCLUDE exporting parameter.

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 statusSTANDARD_FULLSCREEN.

  DATA : FUN TYPE TABLE OF RSEUL_FUN.
  DATA : WA_FUN LIKE LINE OF FUN.
  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.

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.

  DATA : IT_EXCLUDE TYPE SLIS_T_EXTAB,
         WA_EXCLUDE TYPE SLIS_EXTAB.
  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.

Full and Final Code

REPORT ZSAPN_ALV_FUNCTIONS.
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.

hiding ALV function buttons

Learner Questions


No Questions by learners, be first one to ask ..!!

    Please Sign in to ask a question

    Was this lesson helpful to you? Yes No 18 People out of 18 think this lesson helpful


    Lesson Navigation

    ←Previous Chapter
    Next Chapter →