Application Development and Automation 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: 
Read only

alv grid control toolbar exclude generic functions

Former Member
0 Likes
12,420

Hi,

I'm attempting to exclude certain functions from the toolbar of an (editable) alv grid (of class cl_gui_alv_grid).

The problem is that the buttons still show on the toolbar.

My program is based on the SAP example program 'BCALV_EDIT_03'. It would seem that even this example doesn't work as expected.

This is an extract of my code:

-[EXTRACT <b></b>BEGIN]--


*---Restrict generic functions to 'change only'.
*   (i.e The user should not be able to add new lines).
  DATA ls_exclude TYPE ui_func.
  DATA: lt_exclude TYPE ui_functions.

  ls_exclude = cl_gui_alv_grid=>mc_fc_loc_delete_row.
  APPEND ls_exclude TO lt_exclude.
  ls_exclude = cl_gui_alv_grid=>mc_fc_loc_append_row.
  APPEND ls_exclude TO lt_exclude.
  ls_exclude = cl_gui_alv_grid=>mc_fc_loc_insert_row.
  APPEND ls_exclude TO lt_exclude.

*...initialize alv grid
    CALL METHOD g_grid->set_table_for_first_display
      EXPORTING
        is_layout            = ps_layout
        it_toolbar_excluding = lt_exclude
      CHANGING
        it_fieldcatalog      = pt_fieldcat
        it_outtab            = pt_outtab.

-[EX<b></b>TRACT END]--


Thank You In Advance,

Nhlanhla

1 ACCEPTED SOLUTION
Read only

Former Member
4,329

Hi,

i've done similar one, i am able to exclude.

DATA: LT_EXCLUDE TYPE UI_FUNCTIONS.
PERFORM EXCLUDE_TB_FUNCTIONS CHANGING LT_EXCLUDE.
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.
  LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_COPY.
  APPEND LS_EXCLUDE TO PT_EXCLUDE.
  LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_CUT.
  APPEND LS_EXCLUDE TO PT_EXCLUDE.
  LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_PASTE.
  APPEND LS_EXCLUDE TO PT_EXCLUDE.
  LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_PASTE_NEW_ROW.
  APPEND LS_EXCLUDE TO PT_EXCLUDE.
  LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_UNDO.
  APPEND LS_EXCLUDE TO PT_EXCLUDE.
ENDFORM.                               " EXCLUDE_TB_FUNCTIONS

"can you check the LT_EXCLUDE in debug mode.

regards

vijay

Hi,

I'm attempting to exclude certain functions from the toolbar of an (editable) alv grid (of class cl_gui_alv_grid).

The problem is that the buttons still show on the toolbar.

My program is based on the SAP example program 'BCALV_EDIT_03'. It would seem that even this example doesn't work as expected.

This is an extract of my code:

-[EXTRACT <b></b>BEGIN]--


*---Restrict generic functions to 'change only'.
*   (i.e The user should not be able to add new lines).
  DATA ls_exclude TYPE ui_func.
  DATA: lt_exclude TYPE ui_functions.

  ls_exclude = cl_gui_alv_grid=>mc_fc_loc_delete_row.
  APPEND ls_exclude TO lt_exclude.
  ls_exclude = cl_gui_alv_grid=>mc_fc_loc_append_row.
  APPEND ls_exclude TO lt_exclude.
  ls_exclude = cl_gui_alv_grid=>mc_fc_loc_insert_row.
  APPEND ls_exclude TO lt_exclude.

*...initialize alv grid
    CALL METHOD g_grid->set_table_for_first_display
      EXPORTING
        is_layout            = ps_layout
        it_toolbar_excluding = lt_exclude
      CHANGING
        it_fieldcatalog      = pt_fieldcat
        it_outtab            = pt_outtab.

-[EX<b></b>TRACT END]--


Thank You In Advance,

Nhlanhla

5 REPLIES 5
Read only

athavanraja
Active Contributor
0 Likes
4,329

Welcome to SDN.

Check out the following thread for solution to your problem

Regards

Raja

Reward the helpful answers by clicking the radiobutton

Read only

0 Likes
4,329

Durairaj,

I've actually had a look at this thread before I logged mine. However, it didn't help.

But thanks for the speedy response.

Read only

Former Member
4,330

Hi,

i've done similar one, i am able to exclude.

DATA: LT_EXCLUDE TYPE UI_FUNCTIONS.
PERFORM EXCLUDE_TB_FUNCTIONS CHANGING LT_EXCLUDE.
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.
  LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_COPY.
  APPEND LS_EXCLUDE TO PT_EXCLUDE.
  LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_CUT.
  APPEND LS_EXCLUDE TO PT_EXCLUDE.
  LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_PASTE.
  APPEND LS_EXCLUDE TO PT_EXCLUDE.
  LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_PASTE_NEW_ROW.
  APPEND LS_EXCLUDE TO PT_EXCLUDE.
  LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_UNDO.
  APPEND LS_EXCLUDE TO PT_EXCLUDE.
ENDFORM.                               " EXCLUDE_TB_FUNCTIONS

"can you check the LT_EXCLUDE in debug mode.

regards

vijay

Read only

0 Likes
4,329

Thank You Kindly Vijay Babu Dudla,

This has solved my problem but I suppose I should ask why?

Clearly there is an intricate combination to excluding these functions.

Nhlanhla

Read only

0 Likes
4,329

Hi,

all these are interlinked, so you should exclude all of them together.

regards

vijay