rspec/rules/S1671/abap/rule.adoc

55 lines
1.4 KiB
Plaintext
Raw Normal View History

== Why is this an issue?
2021-04-28 16:49:39 +02:00
When several lines must be inserted/updated into an internal table, instead of doing those changes line by line, mass operations should be used because they offer better performance by design.
This rule raises an issue when a single line operation like ``++APPEND++``, ``++CONCATENATE++``, and ``++INSERT++`` is performed on an internal table in a loop.
=== 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 ITAB1 INTO WA.
APPEND WA TO ITAB2.
ENDLOOP.
----
=== 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
----
APPEND LINES OF ITAB1 TO ITAB2.
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
Remove the nesting loop structure and use the "XXX LINES OF ... TO" mass operation clause
'''
== Comments And Links
(visible only on this page)
=== is duplicated by: S2244
=== on 30 Apr 2014, 15:38:55 Nicolas Peru wrote:
Not really sure of what to do with this rule in fact.
Here the example are not equivalent in functional terms : compliant copy STRUC into ITAB and non compliant iterate through a table to do a write statement.
\[~ann.campbell.2] Maybe, you can provide some reference where the rule originated ?
=== on 30 Apr 2014, 15:53:32 Nicolas Peru wrote:
Rule originated from \http://www.dsag.de/fileadmin/media/Leitfaeden/Leitfaden_Best_Practice_Guide_eng/files/assets/basic-html/page20.html
endif::env-github,rspecator-view[]