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

Help reg editable ALV grid

Former Member
0 Likes
1,177

Hi all,

My requirement is to hide the append row button in editable alv grid based on the condition, say if one has appended 20 rows then I need to disable the button so that only n rows could be appended.

I searched in the forum and also looked some standard alv programs but can't' find something relevant.

Pls can anyone suggest me regarding. Is there any standard method (I'm using classes) available for the same.

Thanks and Regards,

Revathi.

Hi all,

My requirement is to hide the append row button in editable alv grid based on the condition, say if one has appended 20 rows then I need to disable the button so that only n rows could be appended.

I searched in the forum and also looked some standard alv programs but can't' find something relevant.

Pls can anyone suggest me regarding. Is there any standard method (I'm using classes) available for the same.

Thanks and Regards,

Revathi.

7 REPLIES 7
Read only

Former Member
0 Likes
1,005

Hi,

Check this example,

http://wiki.sdn.sap.com/wiki/display/ABAP/HIDEToolbarbuttonsinALV

Regards and Best wishes.

Read only

0 Likes
1,005

Hi,

Thanks for your response. Th link addressed only the normal scenario and doesn't suit my requirement.

Regards,

Revathi.

Read only

Former Member
0 Likes
1,005

You need to use parameter IT_TOOLBAR_EXCLUDING in SET_TABLE_FOR_FIRST_DISPLAY. In that, pass internal table of type UI_FUNCTIONS. In UI_FUNCTIONS append MC_FC_LOC_APPEND_ROW attribute.

Eg:

CALL METHOD o_grid->set_table_for_first_display

exporting

IT_TOOLBAR_EXCLUDING = lt_func

CHANGING

it_outtab = lt_vbak

IT_FIELDCATALOG = lt_fcat.

endif.

endform. " displayvbak

form exclude .

lv_func = cl_gui_alv_grid=>MC_FC_LOC_APPEND_ROW.

append lv_func to lt_func.

lv_func = cl_gui_alv_grid=>mc_fc_print.

append lv_func to lt_func.

endform. " exclude

Read only

0 Likes
1,005

Hi,

Thanks for the reply. I have used the same but i need to enable and disable insert button based on condition, say if one has clicked insert button 10 times, then it should be disabled. Hope its clear now.

Thanks,

Revathi.

Read only

0 Likes
1,005

Hi trevathi ,

I had a similar requirement. I made a make-shift arrangement for this.

Removed the whole toolbar and used SET_TOOLBAR_BUTTONS and displayed all the buttons which were needed. REMEMBER !! This method is protected so you cant use it directly. TRICK !! cl_gui_alv_grid has to be imported in your local class and then access SET_TOOLBAR_BUTTONS. in this, pass the table of type TOOLBAR_TABLE append all the buttons you need.

There is a field DISABLED in structure STB_BUTTON using this, you can disable the toolbar button.

Read only

0 Likes
1,005

Hi yuvaraj,

Can u pls guide me how to import the class into a local class. I'm getting error " Access to protected method is not allowed".

Thanks,

Revathi.

Read only

0 Likes
1,005

Hi trevathi,

Here is the code which shows how you can access protected method SET_TOOLBAR_BUTTONS

REPORT  YTEST5                                  .


data : cont type ref to cl_gui_custom_container.

data lt_toolbar type TTB_BUTTON.

class lcl_alv_grid  DEFINITION create public INHERITING FROM cl_gui_alv_grid.
  PUBLIC SECTION.
    methods m1.
endclass.

class lcl_alv_grid IMPLEMENTATION.
    method m1.
        
      CALL METHOD  SET_TOOLBAR_BUTTONS 
      EXPORTING 
        
        TOOLBAR_TABLE = lt_toolbar.
        
    ENDMETHOD.
endclass.


START-OF-SELECTION.
data : o_alv_grid type ref to lcl_alv_grid.


create object cont EXPORTING
           CONTAINER_NAME    = 'CUST_CONT'.

       CREATE OBJECT o_alv_grid
         EXPORTING
           I_PARENT          = CONT.


CALL METHOD o_alv_grid->m1.

Please let me know if you need any further information.