rspec/rules/S5769/abap/rule.adoc
Fred Tingaud 16f6c0aecf
Inline adoc when include has no additional value (#1940)
Inline adoc files when they are included exactly once.

Also fix language tags because this inlining gives us better information
on what language the code is written in.
2023-05-25 14:18:12 +02:00

58 lines
1.2 KiB
Plaintext

== Why is this an issue?
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.
=== Noncompliant code example
[source,abap]
----
LOOP AT i_bseg INTO wa_bseg.
...
wa_bseg-sgtxt = 'VALUE'.
MODIFY i_bseg FROM wa_bseg.
ENDLOOP.
----
=== Compliant solution
[source,abap]
----
LOOP AT i_bseg ASSIGNING <fs_bseg>.
...
<fs_bseg>-sgtxt = 'VALUE'.
ENDLOOP.
----
== Resources
* https://zevolving.com/use-of-field-symbols-vs-work-area/[Use of Field-symbols vs Work area]
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== 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
endif::env-github,rspecator-view[]