rspec/rules/S2240/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

36 lines
1.0 KiB
Plaintext

== Why is this an issue?
Using ``++EXIT++`` and ``++CHECK++`` in ``++SELECT++`` statements to stop the execution of ``++SELECT++`` loop is an expensive and ineffective way to filter data. Filtering should be part of the ``++SELECT++`` loop themselves. Most of the time conditions located in a ``++CHECK++`` statement should be moved to the ``++WHERE++`` clause, and the ``++EXIT++`` statement should typically be replaced by an ``++UP TO 1 ROW++`` clause.
=== Noncompliant code example
[source,abap]
----
SELECT * FROM SBOOK INTO SBOOK_WA.
CHECK: SBOOK_WAS-CARRID = 'LH' AND SBOOK_WAS-CONNID = '0400'. "Noncompliant
ENDSELECT.
----
=== Compliant solution
[source,abap]
----
SELECT * FROM SBOOK INTO SBOOK_WA WHERE CARRID = 'LH' AND CONNID = '0400'.
ENDSELECT.
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
Refactor this piece of code to not stop the execution of the nesting "SELECT" loop before having read all the elements
endif::env-github,rspecator-view[]