You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Incorrect DATA to FINAL conversion when row is modified inside LOOP AT GROUP #540
ABAP cleaner promotes DATA(...) to FINAL(...) when the variable is written through LOOP AT GROUP, causing runtime error
Summary
ABAP cleaner incorrectly converts DATA(var) = ... to FINAL(var) = ... when the table is later modified via a LOOP AT ... GROUP BY ... ASSIGNING <group> followed by an inner LOOP AT GROUP <group> ASSIGNING <row> that writes to a component of <row>.
Because the write to the source table happens through two levels of indirection (group reference → LOOP AT GROUP → row field-symbol), the cleaner's data-flow analysis does not see it as a write and treats the variable as eligible for FINAL. After formatting, executing the code dumps because the anonymous data object behind FINAL(...) is immutable.
Environment
ABAP cleaner: v1.27.0
Steps to reproduce
Create the report below (note the unformatted DATA(rows) = read_rows( ).).
Run ABAP cleaner on the source — the line is rewritten to FINAL(rows) = read_rows( )..
Activate and execute. A runtime error is raised at <row>-value = <row>-value * 10..
Minimal reproducible example
*&---------------------------------------------------------------------**& Report ZR_CLEANER_FINAL_GROUP_BUG*&---------------------------------------------------------------------*REPORT zr_cleaner_final_group_bug.
CLASSlcl_demo DEFINITION.
PUBLIC SECTION.
TYPES: BEGIN OF ty_row,
group_key TYPE i,
value TYPE i,
END OF ty_row,
tt_rows TYPE STANDARD TABLE OF ty_row WITHEMPTY KEY.
METHODSrun.
PRIVATE SECTION.
METHODS read_rows RETURNINGVALUE(result) TYPE tt_rows.
ENDCLASS.
CLASSlcl_demo IMPLEMENTATION.
METHODread_rows.
result=VALUE #( ( group_key =1value=10 )
( group_key =1value=20 )
( group_key =2value=30 ) ).
ENDMETHOD.
METHODrun.
" Before ABAP cleaner: DATA(rows) = read_rows( )." After ABAP cleaner: FINAL(rows) = read_rows( ).DATA(rows) = read_rows( ).
LOOP ATrowsINTODATA(key_for_grouping)
GROUPBY ( group_key = key_for_grouping-group_key )
ASSIGNINGFIELD-SYMBOL(<group>).
LOOP ATGROUP<group>ASSIGNINGFIELD-SYMBOL(<row>).
" <row> points into `rows`. If `rows` is FINAL, this write dumps.<row>-value =<row>-value *10.
ENDLOOP.
ENDLOOP.
LOOP ATrowsASSIGNINGFIELD-SYMBOL(<out>).
WRITE: /<out>-group_key, <out>-value.
ENDLOOP.
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
NEW lcl_demo( )->run( ).
Activity
jmgrassau commentedon Jul 6, 2026
Hi Benedikt,
excellent, thanks for this example! This write access check must be recursive … the bug should be fixed with the next release.
Kind regards,
Jörg-Michael
fix FinalVariableRule for recursive write access (#540)
jmgrassau commentedon Jul 9, 2026
Hi Benedikt,
thanks again for reporting this bug! This should now be fixed with version 1.28.5, which was just released!
Kind regards,
Jörg-Michael