IS ASSIGNED after READ TABLE or ASSIGN in a loop

 home quick fix  single file   example  edit

is_assigned_in_loop

Description

Reports IS [NOT] ASSIGNED after a READ TABLE ... ASSIGNING or ASSIGN inside a loop, without UNASSIGN before it

Extended Information

A failed READ TABLE ... ASSIGNING or ASSIGN keeps the previous binding of the field symbol. Inside a
loop, the field symbol still points to the row of an earlier iteration, so IS ASSIGNED is true
although the statement failed, and the code goes on with the wrong row.

Add UNASSIGN before the statement, inside the loop, or check sy-subrc after a READ TABLE.
The quick fix inserts the UNASSIGN; it is not offered for a field symbol declared inline in
the statement, or for a chained statement.

Not reported: a check that also reads sy-subrc, an ASSIGN that cannot fail (a static source
without dereference, table expression or dynamic part), and loops outside of the
method, form or function module of the statement. See also subrc_after_assign.

Default Configuration

Hover to see descriptions, Ctrl+Space for suggestions

Examples