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: 

ALV : hide standard button

Former Member
0 Kudos

Hi,

is it possible to hide button in standard ALV ?

Thanks

Regards,

1 ACCEPTED SOLUTION

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Yes. Use the exclude functionality.

* Optionally restrict generic functions to 'change only'.

  DATA: LT_EXCLUDE TYPE UI_FUNCTIONS.
*
* (The user shall not be able to add new lines).
*
<b>  PERFORM EXCLUDE_TB_FUNCTIONS CHANGING LT_EXCLUDE.</b>
*

* Set selection mode to "D"  --  Multiple Lines
  LAYOUT-SEL_MODE = 'D'.

  CALL METHOD ALV_GRID->SET_TABLE_FOR_FIRST_DISPLAY
      EXPORTING
           IS_LAYOUT              = LAYOUT
<b>           IT_TOOLBAR_EXCLUDING   = LT_EXCLUDE</b>
           IS_VARIANT             = VARIANT
           I_SAVE                 = 'A'
           I_STRUCTURE_NAME       = 'IALV'
      CHANGING
           IT_OUTTAB       = IALV[]
           IT_FIELDCATALOG = FIELDCAT[].
*
*

<b>FORM EXCLUDE_TB_FUNCTIONS CHANGING PT_EXCLUDE TYPE UI_FUNCTIONS.
* Only allow to change data not to create new entries (exclude
* generic functions).

  DATA LS_EXCLUDE TYPE UI_FUNC.

  LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_COPY_ROW.
  APPEND LS_EXCLUDE TO PT_EXCLUDE.
  LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_DELETE_ROW.
  APPEND LS_EXCLUDE TO PT_EXCLUDE.
  LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_APPEND_ROW.
  APPEND LS_EXCLUDE TO PT_EXCLUDE.
  LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_INSERT_ROW.
  APPEND LS_EXCLUDE TO PT_EXCLUDE.
  LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_MOVE_ROW.
  APPEND LS_EXCLUDE TO PT_EXCLUDE.

ENDFORM.</b>

You can find all of the function codes for the buttons in the class CL_GUI_ALV_GRID, look at the attributes tab, and check out all of the attributes that start with MC_FC*

Regards,

Rich Heilman

3 REPLIES 3

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Yes. Use the exclude functionality.

* Optionally restrict generic functions to 'change only'.

  DATA: LT_EXCLUDE TYPE UI_FUNCTIONS.
*
* (The user shall not be able to add new lines).
*
<b>  PERFORM EXCLUDE_TB_FUNCTIONS CHANGING LT_EXCLUDE.</b>
*

* Set selection mode to "D"  --  Multiple Lines
  LAYOUT-SEL_MODE = 'D'.

  CALL METHOD ALV_GRID->SET_TABLE_FOR_FIRST_DISPLAY
      EXPORTING
           IS_LAYOUT              = LAYOUT
<b>           IT_TOOLBAR_EXCLUDING   = LT_EXCLUDE</b>
           IS_VARIANT             = VARIANT
           I_SAVE                 = 'A'
           I_STRUCTURE_NAME       = 'IALV'
      CHANGING
           IT_OUTTAB       = IALV[]
           IT_FIELDCATALOG = FIELDCAT[].
*
*

<b>FORM EXCLUDE_TB_FUNCTIONS CHANGING PT_EXCLUDE TYPE UI_FUNCTIONS.
* Only allow to change data not to create new entries (exclude
* generic functions).

  DATA LS_EXCLUDE TYPE UI_FUNC.

  LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_COPY_ROW.
  APPEND LS_EXCLUDE TO PT_EXCLUDE.
  LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_DELETE_ROW.
  APPEND LS_EXCLUDE TO PT_EXCLUDE.
  LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_APPEND_ROW.
  APPEND LS_EXCLUDE TO PT_EXCLUDE.
  LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_INSERT_ROW.
  APPEND LS_EXCLUDE TO PT_EXCLUDE.
  LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_MOVE_ROW.
  APPEND LS_EXCLUDE TO PT_EXCLUDE.

ENDFORM.</b>

You can find all of the function codes for the buttons in the class CL_GUI_ALV_GRID, look at the attributes tab, and check out all of the attributes that start with MC_FC*

Regards,

Rich Heilman

Former Member
0 Kudos

Hi

Yes! but depend on whick kind of ALV you're using.

In REUSE_ALV_LIST_DISPLAY and REUSE_ALV_GRID_DISPLAY you can use the parameter IT_EXCLUDING to indicate which buttons hve to be disactived.

In method SET_TABLE_FOR_FIRST_DISPLAY (of class CL_GUI_ALV_GRID) you can use the parameter IT_TOOLBAR_EXCLUDING.

Max

0 Kudos

Thanks so much to both