ABAP SmartFix
Auto Fix ATC Findings, Pragmas and Modern Syntax for SAP ABAP
A VS Code extension for SAP ABAP development. It lists the ATC / Code Inspector findings in your ABAP code and fixes them automatically:
- Safe rewrites are applied to the code directly, e.g.
SELECT SINGLE → SELECT … UP TO 1 ROWS … ENDSELECT, MOVE a TO b → b = a, commenting out BREAK-POINT.
- Everything else gets a Pragma (
##…) or Pseudo Comment ("#EC …), placed at the right position even in multi-line and chained statements.
- Anything that can be done neither way is marked for manual fixing, and a complete prompt can be generated for your AI assistant.
Requirements
VS Code 1.75 or later. No Node.js and no SAP connection needed.
Usage
Open an .abap file and run ABAP SmartFix: Analyze Current File (from the editor context menu, the editor title button, or automatically on save).
Findings are shown in:
- Problems panel: one diagnostic per finding; auto-fixable ones are marked
[Auto-fixable].
- ABAP SmartFix sidebar: findings grouped by file with their fix; click one to jump to the line.
- Status bar: the total number of findings.
While you type, an analyzed file is analyzed again once typing pauses (about 0.5 s), so line numbers stay current.
Closing a file removes its findings; files that were only scanned by Analyze Workspace and never opened stay listed.
Right-click in the editor and pick how to fix them:
| To do this |
Command |
| See the changes first |
ABAP SmartFix: Preview Fixes |
| Fix automatically (rewrites + annotations, asks first) |
ABAP SmartFix: Auto Fix Current File |
| Only add annotations, leave the code as is |
ABAP SmartFix: Add Pragmas & Pseudo Comments Only |
| Hand it to an AI assistant |
ABAP SmartFix: Copy AI Prompt, then paste it |
| Fix a single line |
Put the cursor on the line → Ctrl+. → pick a Quick Fix |
To fix a whole project, use Analyze Workspace and then Auto Fix All Scanned Files in the sidebar.
All changes are applied as one edit, so a single Ctrl+Z undoes them; files are not saved automatically.
More commands: Generate Markdown Report, Export JSON, Show Rules, Clear Results.
After an auto fix, run the syntax check and ATC again in your SAP system.
Auto fix on save
"[abap]": {
"editor.codeActionsOnSave": { "source.fixAll.abap-smartfix": "explicit" }
}
Supported checks
| Annotation |
Check |
Rewrite |
"#EC CI_SUBRC / ##SUBRC_OK |
sy-subrc not checked after database access, READ TABLE, AUTHORITY-CHECK, etc. |
|
"#EC CI_NOFIELD |
SELECT * |
|
"#EC CI_NOORDER |
SELECT … INTO TABLE without ORDER BY whose result is later used in an order-dependent way |
✅ |
##WARN_OK |
SELECT SINGLE that clearly does not use the full primary key |
✅ |
"#EC CI_NOWHERE |
SELECT without WHERE |
|
"#EC CI_SEL_NESTED |
SELECT inside a loop |
|
"#EC CI_DYNTAB |
Dynamic table name, field list or WHERE condition |
|
"#EC CI_CLIENT |
CLIENT SPECIFIED |
|
"#EC CI_STDSEQ |
Linear search on a standard table |
|
"#EC CI_SORTSEQ |
SORT without BY |
|
"#EC CI_CALL_TA / "#EC CI_SUBMIT |
CALL TRANSACTION / SUBMIT |
|
"#EC NOBREAK |
BREAK-POINT / BREAK user |
✅ |
##NO_HANDLER |
Empty CATCH block |
|
##NEEDED |
Declared but never used |
✅ |
##NO_TEXT |
Text literal without a text symbol |
|
##CALLED |
FORM without a matching PERFORM (off by default) |
|
| — |
Obsolete syntax: MOVE, ADD, COMPUTE, REFRESH, DESCRIBE TABLE … LINES, CALL METHOD, CREATE OBJECT, GET REFERENCE OF |
✅ |
| — |
Obsolete pseudo comments to pragmas: "#EC NEEDED → ##NEEDED, etc. |
✅ |
Run Show Rules for each rule's id and exact trigger conditions.
Settings
| Setting |
Default |
Description |
abap-smartfix.fixMode |
auto |
auto: apply only rewrites with identical semantics, annotate the rest; rewrite: also apply rewrites that need review; suppress: only add annotations |
abap-smartfix.ruleFixModes |
{} |
Fix mode per rule, overriding fixMode |
abap-smartfix.suppressStyle |
rule |
When a rule has both forms, always use pragma or pseudo |
abap-smartfix.disabledRules |
[] |
Rule ids to disable |
abap-smartfix.enabledRules |
[] |
Rule ids to enable that are off by default |
abap-smartfix.tokenOverrides |
{} |
Use the annotation names of your own system |
abap-smartfix.selectSingleCheck |
certain |
How SELECT SINGLE is judged: certain or all |
abap-smartfix.diagnosticSeverity |
information |
Severity in the Problems panel; auto uses each rule's own |
abap-smartfix.scanOnSave / scanOnOpen |
true / false |
Analyze automatically on save / on open |
abap-smartfix.scanOnType |
true |
Analyze an already analyzed file again about 0.5 s after typing stops |
abap-smartfix.include / exclude / maxFiles |
|
Scope and file limit for analyzing the workspace |
abap-smartfix.customRulesFile |
.abap-smartfix-rules.json |
Custom rules file |
Example:
{
"abap-smartfix.suppressStyle": "pragma",
"abap-smartfix.ruleFixModes": { "select-single": "suppress" },
"abap-smartfix.disabledRules": ["select-no-order-by"]
}
Custom rules
Put a .abap-smartfix-rules.json in the workspace root to add annotation or rewrite rules:
[
{
"id": "commit-work",
"token": "\"#EC CI_COMMIT",
"title": "COMMIT WORK",
"match": "^COMMIT\\s+WORK\\b"
},
{
"id": "translate-upper",
"title": "TRANSLATE … TO UPPER CASE → to_upper( )",
"match": "^TRANSLATE\\s+(\\S+)\\s+TO\\s+UPPER\\s+CASE$",
"replace": "$1 = to_upper( $1 )"
}
]
match is tested against a single statement (multi-line statements are joined and comments removed). A token starting with ## is a Pragma; anything else is a Pseudo Comment.
replace can use $1, $2. Other fields: notMatch, flags, why, severity, safety (safe / review), enabled.
Known issues
- This is a lightweight syntax scanner, not a full ABAP parser. It cannot see macro expansion,
INCLUDE chains, cross-program calls or DDIC information.
- Accepted annotation names can differ between SAP releases and custom ATC checks. Go by the messages in your system and adjust with
abap-smartfix.tokenOverrides if needed.
##NEEDED only looks at the current file. Global declarations in TOP includes are skipped to avoid flagging variables used in other includes or dynpros.
- Annotations only make ATC skip a check; they do not improve the code. Real problems (such as a
SELECT inside a loop) are better fixed in code.
If you find a false positive or a missed finding, please report it with a minimal code sample.
Trademarks
SAP, ABAP and other SAP products and services mentioned herein are trademarks or registered trademarks of SAP SE in Germany and other countries. ABAP SmartFix is an independent project and is not affiliated with, endorsed by or sponsored by SAP SE.
License
MIT. See the LICENSE file included with the extension.