2023-05-03 11:06:20 +02:00
== Why is this an issue?
2021-04-28 16:49:39 +02:00
Using ``++LOOP...INTO++`` with ``++MODIFY++`` statements will put the required record in a work area, process it and put it back in the internal table. It is more efficient to modify the internal table directly by using ``++LOOP...ASSIGNING++`` and field-symbols.
This rule raises an issue when a ``++LOOP...INTO++`` contains one or more ``++MODIFY++`` statements.
2021-04-28 18:08:03 +02:00
2023-05-03 11:06:20 +02:00
=== Noncompliant code example
2021-04-28 16:49:39 +02:00
2022-02-04 17:28:24 +01:00
[source,abap]
2021-04-28 16:49:39 +02:00
----
LOOP AT i_bseg INTO wa_bseg.
...
wa_bseg-sgtxt = 'VALUE'.
MODIFY i_bseg FROM wa_bseg.
ENDLOOP.
----
2021-04-28 18:08:03 +02:00
2023-05-03 11:06:20 +02:00
=== Compliant solution
2021-04-28 16:49:39 +02:00
2022-02-04 17:28:24 +01:00
[source,abap]
2021-04-28 16:49:39 +02:00
----
LOOP AT i_bseg ASSIGNING <fs_bseg>.
...
<fs_bseg>-sgtxt = 'VALUE'.
ENDLOOP.
----
2021-04-28 18:08:03 +02:00
2023-05-03 11:06:20 +02:00
== Resources
2021-04-28 16:49:39 +02:00
2021-06-18 12:41:18 +02:00
* https://zevolving.com/use-of-field-symbols-vs-work-area/[Use of Field-symbols vs Work area]
2021-04-28 18:08:03 +02:00
2021-09-20 15:38:42 +02:00
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
2023-05-25 14:18:12 +02:00
=== Message
Replace this "LOOP INTO" and "MODIFY" with "LOOP ASSIGNING" and field-symbols.
=== Highlighting
Primary: the whole LOOP...INTO statement, but not the body of the loop.
Secondary:
* Every "MODIFY" statement
* message: replace this "MODIFY" with a field-symbol
2021-09-20 15:38:42 +02:00
endif::env-github,rspecator-view[]