abapOpenChecks - Installation - Checks - Utilities - Links

CHECK_62 - LOOP simplification/performance

Improve this page
RFC enabled
CODE

Use DELETE WHERE instead

LOOP AT lt_tab ASSIGNING <fs> WHERE ...
  DELETE lt_tab FROM <fs>.
ENDLOOP.

It should be replaced with:

DELETE lt_tab WHERE ...

Ref: https://wiki.scn.sap.com/wiki/display/ABAP/How+to+avoid+modify+and+delete+statements+inside+loop+end+loop+using+field+symbols

Checking for lines before looping

IF lines( lt_tab ) > 0
  LOOP AT lt_tab ASSIGNING <fs> WHERE ...
    ...
  ENDLOOP.
ENDIF.

can be reduced to

LOOP AT lt_tab ASSIGNING <fs> WHERE ...
  ...
ENDLOOP.

Continue as last statement in loop

LOOP AT lt_tab ASSIGNING <fs> WHERE ...
  ...
  CONTINUE.
ENDLOOP.

can be reduced to

LOOP AT lt_tab ASSIGNING <fs> WHERE ...
  ...
ENDLOOP.

Configuration

Configuration