Code Quality: ATC, Code Inspector & Clean ABAP
Typical findings: SELECT without WHERE, SELECT in loops, missing AUTHORITY-CHECK, hard-coded BREAK-POINT, unused variables, sy-subrc not checked, dynamic SQL without escaping (security), obsolete statements, use of unreleased APIs.
39.1 Code Inspector (SCI) and ABAP Test Cockpit (ATC)
Code Inspector (SCI/SCII): static analysis with configurable check variants (syntax, performance, security, naming, robust programming).
ATC: the framework built on top of SCI — runs checks centrally, integrates with transport release (block transports with priority 1/2 findings), manages exemptions, and supports remote checks (central ATC system checking older systems, also used for S/4HANA readiness and cloud readiness).
Run from ADT (*Run As → ABAP Test Cockpit*, Ctrl+Shift+F2) or SE80/transaction ATC.
Pseudo-comments / pragmas suppress justified findings: "#EC CI_NOWHERE, ##NEEDED, ##NO_TEXT.
Typical findings: SELECT without WHERE, SELECT in loops, missing AUTHORITY-CHECK, hard-coded BREAK-POINT, unused variables, sy-subrc not checked, dynamic SQL without escaping (security), obsolete statements, use of unreleased APIs.
39.2 Clean ABAP
Clean ABAP is SAP's open-source style guide (github.com/SAP/styleguides), adapting *Clean Code* to ABAP. Highlights:
Descriptive, intention-revealing names; avoid encodings like Hungarian notation (lv_, lt_, ls_) — the guide discourages them, but many teams still use them; be consistent within a codebase
Prefer object orientation over procedural; prefer functional over procedural constructs (NEW, VALUE, table expressions)
Use constants or enumerations (TYPES BEGIN OF ENUM) instead of magic numbers
Prefer inline declarations close to first use; don't declare inline in optional branches
Use the right table type; avoid DEFAULT KEY; prefer INSERT INTO TABLE over APPEND TO; prefer line_exists( ) over READ TABLE … TRANSPORTING NO FIELDS
Use abap_bool, abap_true/abap_false, xsdbool() Try to make conditions positive; avoid deep nesting; prefer IS NOT over NOT IS
Small, do one thing, few parameters (ideally < 3 importing), RETURNING over EXPORTING, no boolean input parameters that switch behavior
FINAL by default; members PRIVATE by default; prefer composition over inheritance; avoid static classes where instances work
Prefer exceptions over return codes; use class-based exceptions; throw CX_STATIC_CHECK for manageable situations
Express yourself in code, not comments; comments explain *why*; delete dead code
Pretty printer consistently; one statement per line; align parameters; max line length ~120
Write testable code, use test doubles, test the public interface, name tests by behavior Enumerations (7.51+):
TYPES: BEGIN OF ENUM ty_status STRUCTURE status,
open,
in_process,
closed,
END OF ENUM ty_status STRUCTURE status.
DATA lv_status TYPE ty_status VALUE status-open.39.3 Tooling
abapLint (open source, abaplint.org): linter for ABAP files in Git (CI on GitHub/GitLab), with many Clean ABAP rules.
Code Pal for ABAP (open-source ATC checks for Clean ABAP; archived in favor of standard ATC checks and abapLint).
ABAP Cleaner (open source, SAP): ADT plugin that automatically applies 90+ Clean ABAP cleanup rules (modern syntax, alignment, declarations) — highly recommended.
Pretty printer settings (keywords upper/lower case, indentation).