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

Modify ALV row without buttons create, delete, refresh

Former Member
0 Likes
2,202

Hi all,

I have an ALV with a button that allows you to modify a field, but I have a problem. I am using

CALL METHOD obj_grid->set_ready_for_input

     EXPORTING

       i_ready_for_input = 1.


but this method add buttons Create, Copy, Delete, Refresh, etc. I want to modify just a field with my created button, without buttons create, delete, refresh, etc on my toolbar. Is that possible?


Thanks for your help

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,196

If you just want to modify a field, then no need to use this method set_ready_for_input.

You can do it by using CL_GUI_ALV_GRID=>MC_STYLE_ENABLED to set a cell
to status "editable".


At the user command module on clicking the edit button,


Get the selected row using CALL METHOD gv_gridref1->get_current_cell_row_id
       IMPORTING
         row_id = gv_row_id.


Read the corresponding record from the ALV table.

Make the fields in this row editable using.

  ls_celltab-fieldname = 'FIELDNAME1'.
   ls_celltab-style = cl_gui_alv_grid=>mc_style_enabled.
   insert ls_celltab INTO TABLE pt_celltab.


  ls_celltab-fieldname = 'FIELDNAME2'.
   ls_celltab-style = cl_gui_alv_grid=>mc_style_enabled.
   INSERT ls_celltab INTO TABLE pt_celltab.


  INSERT LINES OF pt_celltab INTO TABLE gt_outtab-celltab.
   MODIFY gt_outtab INDEX gv_row_id.


Then call the method to refresh table display.


This will make just those fields editable.


Dont forget to add the style field to the data table, and to mention this style field name in the layout.


Refer the report. BCALV_EDIT_02


Also, check this link
ABAP-Changing Cell characteristics in ALV (OOPS) - Code Gallery - SCN Wiki



6 REPLIES 6
Read only

Former Member
0 Likes
1,197

If you just want to modify a field, then no need to use this method set_ready_for_input.

You can do it by using CL_GUI_ALV_GRID=>MC_STYLE_ENABLED to set a cell
to status "editable".


At the user command module on clicking the edit button,


Get the selected row using CALL METHOD gv_gridref1->get_current_cell_row_id
       IMPORTING
         row_id = gv_row_id.


Read the corresponding record from the ALV table.

Make the fields in this row editable using.

  ls_celltab-fieldname = 'FIELDNAME1'.
   ls_celltab-style = cl_gui_alv_grid=>mc_style_enabled.
   insert ls_celltab INTO TABLE pt_celltab.


  ls_celltab-fieldname = 'FIELDNAME2'.
   ls_celltab-style = cl_gui_alv_grid=>mc_style_enabled.
   INSERT ls_celltab INTO TABLE pt_celltab.


  INSERT LINES OF pt_celltab INTO TABLE gt_outtab-celltab.
   MODIFY gt_outtab INDEX gv_row_id.


Then call the method to refresh table display.


This will make just those fields editable.


Dont forget to add the style field to the data table, and to mention this style field name in the layout.


Refer the report. BCALV_EDIT_02


Also, check this link
ABAP-Changing Cell characteristics in ALV (OOPS) - Code Gallery - SCN Wiki



Read only

0 Likes
1,196

Hi Susmitha,

1. I'm trying to put this code CALL METHOD gv_gridref1->get_current_cell_row_id
       IMPORTING
         row_id = gv_row_id.

on my program, and when I try to activate the program, a message prompts, saying that the protected method access GET_CURRENT_CELL_ROW_ID is not allowed. I don't know if I am doing something wrong or really I am not allowed to use that method.

2. The table I'm using is BSIS, and contains 85 fields aprox. Do I have to repeat

ls_celltab-fieldname = 'FIELDNAME1'.
   ls_celltab-style = cl_gui_alv_grid=>mc_style_enabled.
   insert ls_celltab INTO TABLE pt_celltab.


for each field my table contents? or there is a better way to do that?


Thanks,

Read only

0 Likes
1,196

From your initial post, I thought you just wanted to enable a field for editing. If its just a few fields, then use the above suggested method.


If you need to enable the all the 85 fields for editing, then you go for

CALL METHOD obj_grid->set_ready_for_input

     EXPORTING

       i_ready_for_input = 1.

And pass the function codes of the buttons to disable the buttons. Do it in the PAI after calling the above method.


Suppose 'EDIT' is the function code for the button that you created.

Add the following code in the PAI.


MODULE user_command_0100 INPUT.


CASE gv_okcode.


WHEN 'EDIT'.
       CALL METHOD gv_gridref->set_ready_for_input
         EXPORTING
           i_ready_for_input = 1.
       g_exclude = cl_gui_alv_grid=>mc_fc_loc_insert_row.
       APPEND g_exclude TO g_t_tlbr_excl.
       g_exclude = cl_gui_alv_grid=>mc_fc_loc_paste_new_row.
       APPEND g_exclude TO g_t_tlbr_excl.
       g_exclude = cl_gui_alv_grid=>mc_fc_loc_cut.
       APPEND g_exclude TO g_t_tlbr_excl.
       g_exclude = cl_gui_alv_grid=>mc_fc_loc_delete_row.
       APPEND g_exclude TO g_t_tlbr_excl.

      g_exclude = cl_gui_alv_grid=>mc_fc_refresh.

      append g_exclude to g_t_tlbr_excl.

       SORT g_t_tlbr_excl.
       DELETE ADJACENT DUPLICATES FROM g_t_tlbr_excl COMPARING table_line.


ENDCASE.

ENDMODULE


where


DATA :g_exclude          TYPE ui_func,
     g_t_tlbr_excl  TYPE ui_functions.


and g_t_tlbr_excl will be passed as the parameter in set_table_for_first_display method in the PBO.



Read only

0 Likes
1,196

Hii Mario,

You can't access the protected method of CL_GUI_ALV_GRID.

if you need this method any how then in your class defination  add INHERITING FROM cl_gui_alv_grid. Means you have to use inheritance.And if you use inheritance then creating the object of local class you have to pass i_parent parameter value .

OR

You can use method GET_CURRENT_CELL  which hold the current row  public method.

In order to make all fields of BSIS table editable then you can do this through layout like below,

DATA x_layout TYPE LVC_S_LAYO.

x_layout-edit = 'X'.     "Will make all the fields editable.

While calling the method 'SET_TABLE_FOR_FIRST_DISPLAY' specify the is_layout = x_layout as

CALL METHOD obj_grid->set_table_for_first_display

         EXPORTING

          is_layout                      = x_layout          "setting layout

           it_toolbar_excluding    = t_exclude        "To exclude standard toolbar button

         CHANGING

           it_outtab                       = lt_trans

           it_fieldcatalog                = lt_fieldcat

         EXCEPTIONS

           invalid_parameter_combination = 1

           program_error                 = 2

           too_many_lines                = 3

           OTHERS                        = 4.

       IF sy-subrc <> 0.


       ENDIF.


If you  don't want the  Standard TOOLBAR button then you can do this.Go to method CL_GUI_ALV_GRID and in ATTRIBUTE tab they are all listed there.So choose your required one and append to internal table TYPE ui_functions. as illustrated by Susmitha Susan Thomas.


If you don't want any standard toolbar button then you can do this like below,


DATA: t_exclude TYPE ui_functions,

          x_exclude TYPE ui_func.


     x_exclude = cl_gui_alv_grid=>mc_fc_excl_all.                         "To exclude all standard button

     APPEND x_exclude TO t_exclude.

     CLEAR x_exclude.



regards

Syed


Read only

Tomas_Buryanek
Product and Topic Expert
Product and Topic Expert
0 Likes
1,196

Hi Mario,

while you calling obj_grid->set_table_for_first_display, use also parameter it_toolbar_excluding.

In this parameter pass internal table, which you can fill with "button codes" you want exclude from display.


For example "delete row" button:


ls_toolbar_excl   = cl_gui_alv_grid=>mc_fc_loc_delete_row.

APPEND ls_toolbar_excl TO lt_toolbar_excl.

You can find more buttons in cl_gui_alv_grid=>mc_fc*

-- Tomas --
Read only

0 Likes
1,196

Thanks all for your help. Finally, I could solve my issue.