Victoria Ideas All articles

Master cl_gui_alv_grid: Get Changed Rows Like a Pro

Jun 25, 2026 Victoria
CSS Grid Tutorial w/ Cheat Sheet
CSS Grid Tutorial w/ Cheat Sheet

When working with SAP ALV grids in ABAP, developers frequently encounter the need to track modifications made by end-users during data display. The cl_gui_alv_grid class provides a robust mechanism for handling these interactions, and understanding how to retrieve changed rows is crucial for implementing efficient data synchronization logic. This functionality becomes essential in scenarios involving mass updates, approval workflows, or any application where user edits must be selectively processed on the backend.

CSS Grid Tutorial w/ Cheat Sheet
CSS Grid Tutorial w/ Cheat Sheet

Understanding the Data Exchange Mechanism

Complete Beginner CSS Master Notes
Complete Beginner CSS Master Notes

The core of tracking modifications lies in the data exchange between the front-end ALV and the ABAP backend. The grid control maintains an internal table that reflects the current state displayed to the user, which may differ from the original data fetched initially. To synchronize these states, SAP employs a system of packing modified data into a specific structure during the execution of standard SAP events, most notably the on_modify event. This structure acts as a container, capturing not just the altered field values but also their precise location within the dataset, enabling precise change identification.

Implementing the Event Handler

the instructions for how to draw an animal with numbers and symbols on it's sides
the instructions for how to draw an animal with numbers and symbols on it's sides

To capture modifications, you must first establish a connection between the grid and your event handling logic. This involves setting the i_parent reference and registering the method that will process the on_modify event. The registration is typically performed directly after creating the ALV instance using the set_ready_for_input method with a function code that triggers the frontend service. Without this registration, the system will not generate the necessary data packet detailing the user's actions, rendering change tracking impossible.

The Structure of Modified Data

pink squares are arranged in rows on a white background, with one square at the center
pink squares are arranged in rows on a white background, with one square at the center

The event on_modify passes a table of type LVC_T_MODI to the implementing method. This table is the key to identifying changed rows, as each entry corresponds to a specific cell alteration. Each structure in this table contains critical fields: ROW_ID and FIELDNAME. The ROW_ID is particularly important as it represents the logical key of the modified line, usually correlating with the initial table index or a specific key field defined in the layout. By analyzing this table, you can determine exactly which rows require processing on the database level.

Field Name Data Type Description
ROW_ID CHAR 10 Identifies the modified line in the internal table.
FIELDNAME CHAR 30 Holds the name of the field that was modified.
VALUE_NEW CHAR 255 Contains the new value entered by the user.

Extracting the Changed Rows

Coding - 🚀 30 Days CSS Series!  Day 19: CSS Grid 🔥 | Facebook
Coding - 🚀 30 Days CSS Series! Day 19: CSS Grid 🔥 | Facebook

While the LVC_T_MODI table provides granular cell-level data, the ultimate goal is often to isolate the complete rows that have been altered. To achieve this, you iterate through the modification table and collect the unique ROW_ID values into a separate index table or standard table of row identifiers. Since a single row may contain multiple changed fields, it is vital to use a check to ensure that each row is only added to the change list once. This collection phase transforms low-level cell modifications into actionable business object updates.

Synchronizing with the Database

Once the list of changed row identifiers is compiled, the next phase involves updating the persistent database tables. This step requires a loop through the main internal table containing the current display data, cross-referenced with your list of changed row IDs. For performance optimization, it is generally recommended to prepare an update table and execute a single `MODIFY` or `UPDATE` statement for the entire batch rather than issuing individual database commits for each row. This approach minimizes database overhead and ensures transactional integrity during the save process.

CSS Grid vs Flexbox: Decision Tree to Choose the Right Layout Fast
CSS Grid vs Flexbox: Decision Tree to Choose the Right Layout Fast

Handling Optimistic Locking

In multi-user environments, concurrent data access can lead to update conflicts that must be managed gracefully. When processing the changed rows identified by `ROW_ID`, the system should implement optimistic locking checks using the `SYSTEM-COMMAND` field or the `COL_POS` system field within the modification structure. If a conflict is detected—meaning the underlying database record has been altered by another user since the ALV was displayed—the application should notify the specific row to the user rather than performing a blind overwrite. This ensures data consistency and prevents accidental loss of recent modifications.

15 Mystery Grid Drawing Worksheets
15 Mystery Grid Drawing Worksheets
5X5 Grid - 10 Free PDF Printables | Printablee
5X5 Grid - 10 Free PDF Printables | Printablee
The Ultimate Guide To CSS Grid
The Ultimate Guide To CSS Grid
a graph paper with squares in the middle and one line at the bottom that has been drawn
a graph paper with squares in the middle and one line at the bottom that has been drawn
Coding - 🚀 30 Days CSS Series!  Day 16: Flex Container Properties #css #html | Facebook
Coding - 🚀 30 Days CSS Series! Day 16: Flex Container Properties #css #html | Facebook
CSS Grid vs Flexbox: Which Layout System Should You Use?
CSS Grid vs Flexbox: Which Layout System Should You Use?
Git Workflow Roadmap
Git Workflow Roadmap
an image of a man standing in front of a sphere with lines and dots on it
an image of a man standing in front of a sphere with lines and dots on it
How to Insert Multiple Rows in Google Sheets: 5 Easy Ways
How to Insert Multiple Rows in Google Sheets: 5 Easy Ways
Alif Hossain (@alifcoder) on X
Alif Hossain (@alifcoder) on X
Coding - CSS Flexbox vs Grid 🔥  #css | Facebook
Coding - CSS Flexbox vs Grid 🔥 #css | Facebook
How to use (& break) the rule of thirds
How to use (& break) the rule of thirds
a black and white photo of a woman's face with squares in the background
a black and white photo of a woman's face with squares in the background
Claude Code Running Opus 4.8 | Terminal Shortcuts & Developer Workflow Cheat Sheet
Claude Code Running Opus 4.8 | Terminal Shortcuts & Developer Workflow Cheat Sheet
Complete CSS Grid Tutorial with Cheat Sheet 🎖️
Complete CSS Grid Tutorial with Cheat Sheet 🎖️
the guitar chords are arranged in different ways
the guitar chords are arranged in different ways
How to Insert Multiple Rows in Google Sheets: 5 Easy Ways
How to Insert Multiple Rows in Google Sheets: 5 Easy Ways
a graph paper with the number of lines drawn on it and an arrow pointing up to the
a graph paper with the number of lines drawn on it and an arrow pointing up to the
Learn How CSS Grid Properties Work With Griddy.io
Learn How CSS Grid Properties Work With Griddy.io
Claude Code Workflow Cheatsheet
Claude Code Workflow Cheatsheet