ERPClimb logoERPClimb
ALV Reports
ABAP Developmentadvanced 12 min read

ALV Reports Part 9: Editable ALV with CL_GUI_ALV_GRID

Preview · a free account unlocks the full lesson

Key takeaway

Build an editable grid: edit flags in the field catalog, register edit event, check changed data, the DATA CHANGED event with ER DATA CHANGED for validation, and saving changes safely with locks and a single COMMIT.

In this lessonShow sections

Visual overview

ALV Reports Part 9: Editable ALV with CL_GUI_ALV_GRID — learning sheetFlow: Create custom table ZFLIGHT_PRICE (carrid, connid, fldate, price, currency) or use a copy → Run the code example: edit prices, enter a negative value and see the error protocol → Save and check the table in SE16N. Key ideas: WHICH ALV CAN BE EDITED; MAKING COLUMNS EDITABLE; GETTING THE DATA BACK; VALIDATION WITH DATA_CHANGED. Watch out: Editing a table directly is not enough — lock (ENQUEUE), validate, save via the correct API/update and COMMIT once.ERPClimb.com / ABAP / LESSON 9/10 / LEARNING SHEETALV Reports Part 9: Editable ALV with CL_GUI_ALV_GRID1 · HOW IT FLOWS1Create custom tableZFLIGHT_PRICE (carrid,connid, fldate, price…2Run the code exampleedit prices, enter a negativevalue and see the error protocol3Save and check the tablein SE16N2 · KEY IDEAS EXPLAINEDWhich ALV Can Be EditedCL_GUI_ALV_GRID — yes, standard way.REUSE_ALV_GRID_DISPLAY — edit via fieldcat edit ='X' works in a limited way (changes only aftercallbacks); avoid for serious editing.Making Columns EditableField catalog: edit = 'X' on editable columns;keep key columns read-only.Optional per-cell control: a style table(lvc_t_styl) withcl_gui_alv_grid=>mc_style_disabled for rows…Getting The Data Backregister_edit_event( mc_evt_modified ) — raisesDATA_CHANGED when the user leaves a changed cell;mc_evt_enter reacts only on Enter.Before saving: go_grid->check_changed_data( )transfers pending input and triggers validation.Validation With DATA_CHANGEDLoop at er_data_changed->mt_good_cells (row_id,fieldname, value).Wrong value →er_data_changed->add_protocol_entry( i_msgid …i_fieldname … i_row_id … ). The ALV shows an error…3 · REMEMBER · WATCH OUTRememberEditable ALV uses CL_GUI_ALV_GRID: set edit = 'X' in the field catalog(or layout edit = 'X' for all columns).go_grid->register_edit_event( cl_gui_alv_grid=>mc_evt_modified )and check_changed_data( ) move user input into the internal table.Validate in the DATA_CHANGED event:er_data_changed->add_protocol_entry( ) shows errors per cell.!Watch outEditing a table directly is notenough — lock (ENQUEUE), validate,save via the correct API/update andCOMMIT once.4 · IN A REAL PROJECTA pricing team maintained 3,000 freight rates in a custom table through SM30, one screen at a time. Aneditable ALV allowed mass changes with Excel-like editing and immediate validation of negative or zero rates.Two planners once changed the same rates at the same time; the second save overwrote the first. The team added…Original ERPClimb learning sheet • Verify against your SAP release and edition

Explanation

Parts 3 and 8 displayed and processed ALV data for viewing; now users need to change values directly in the grid, which is common for mass maintenance of custom tables or planning values.

Editable ALV relies on CL_GUI_ALV_GRID: you set edit = 'X' in the field catalog for individual columns, or edit = 'X' in the layout to make every column editable. The call go_grid->register_edit_event( cl_gui_alv_grid=>mc_evt_modified ) together with check_changed_data( ) is what actually moves the user's typed input into your internal table.

Validation belongs in the DATA_CHANGED event, where er_data_changed->add_protocol_entry( ) lets you flag errors on specific cells. Editing the table in memory is not the whole job, though — you still need to lock the relevant entries with ENQUEUE, validate the input, save through the correct API or update mechanism, and commit once.

Not every ALV flavor supports real editing. CL_GUI_ALV_GRID is the standard way to do it. REUSE_ALV_GRID_DISPLAY technically supports edit = 'X' in the field catalog, but changes only become visible after callbacks fire, which makes it unreliable for anything beyond trivial cases — avoid it for serious editing. CL_SALV_TABLE isn't built for editing at all.

Free account

Create a free account to keep reading

You have read the opening of this lesson. A free ERPClimb account unlocks the rest of it, every other lesson and topic, and your learning history, so you can pick up exactly where you stopped. No card needed.

  • Full explanation
  • Code example
  • Real project scenario
  • Common mistakes
  • Best practices
  • Interview angle

One tap with Google works too. Every topic keeps its first lesson open to everyone.

Keep exploring

Referenced SAP objects

Reviewed reference pages for the objects this page mentions.

Check before use: lesson examples are educational, not a guarantee of correctness for your SAP edition or release. Sample code has not been executed on your SAP system. Confirm API availability, syntax, authorizations and business impact in an approved development or test environment.