1

I am using the CL_GUI_ALV_GRID class to display a table. I would like to be able to edit the table (adding new rows and removing all lines), but I don't want existing rows to be editable. That means:

I've got 5 records to display, and I would like to be able to remove and add new records but I don't want the user to edit the 5 existing records (I'd like him to be able to remove them).

Is that possible?

Nelson Miranda
  • 5,484
  • 5
  • 33
  • 54
Florian
  • 5,918
  • 3
  • 47
  • 86

1 Answers1

2

By default when you call the 'LVC_FIELDCATALOG_MERGE' function module to generate a field catalog for the CL_GUI_ALV_GRID, the cells are not editable.

You must set which column is going to be edited setting the 'edit' attribute like this:

...
data: it_fieldcat type lvc_t_fcat,
      wa_fieldcat like line of it_fieldcat.

call function 'LVC_FIELDCATALOG_MERGE'
  EXPORTING
    i_structure_name = 'ZSTRUCT'
  CHANGING
    ct_fieldcat      = it_fieldcat.

loop at it_fieldcat into wa_fieldcat.
  wa_fieldcat-edit = 'X'. " ---->Here is set the editable column
  modify it_fieldcat from wa_fieldcat.
endloop.

If you don't want cells to be edited do not set this attribute.

But for better reference check programs 'BCALV_EDIT_03' and 'BCALV_EDIT_04' for complete examples.

Hope it helps.

enter image description here

Nelson Miranda
  • 5,484
  • 5
  • 33
  • 54
  • I already know that, the question is how can I "lock" existing ROWS. For example take a look at the role tab of transaction su01. You can't edit the already applied roles. You can just remove them. – Florian Sep 08 '15 at 19:59
  • @thefiloe Well, then your question is not very clear because transaction 'SU01' doesn't use CL_GUI_ALV_GRID'. On the other hand if you check program 'SAPLSUU5' especifically dynpro '103' there's traditional scheme of table control where it is necessary to manage the data through a table. I haven't done such solution but here's a link that may help you http://help.sap.com/saphelp_470/helpdata/en/9f/dbac5e35c111d1829f0000e829fbfe/content.htm. If you persist on CL_GUI_ALV_GRID then program 'BCALV_EDIT_04' is your best bet. Hope it helps. – Nelson Miranda Sep 08 '15 at 20:40