ABAP Guide: Check Code against Clean ABAP Rules

This content was generated with the assistance of AI and should be verified against the official documentation before being relied on in production.

Checked on 2026-11-13 against abaplint 2.120.103 and Node.js 24.21.

What you build

You check one small ABAP class, zlint_claims, that adds up claim amounts and was written with several bad habits on purpose. First you run abaplint, an open-source static checker for ABAP, with a short configuration of six rules and read its two findings. Then you add three rules that follow SAP’s Clean ABAP style guide, read five findings, and fix the class until the checker reports none. A finding tells you the file, the line and column, what is wrong, and the key of the rule that found it, so you can look the rule up.

abaplint is a community project, not SAP software. It reads ABAP source files without an SAP system and applies the rules you switch on. It is not the ABAP Test Cockpit (ATC) of an SAP system and does not replace it: a clean abaplint run says nothing about ATC. The section Where abaplint fits next to ATC below explains the difference. The ATC checks themselves run only on an SAP system and are not run here.

Terminal showing the result of the guide: npx abaplint lint-demo/abaplint.json reports 0 issues found in 2 files

Before you start

  • No account is needed: abaplint installs from the public npm registry without signing in, and it runs on your computer. The licence (MIT) is listed in the README of the ABAP lab.

  • Set up the lab first, with the guide Set Up a Local ABAP Playground: the folder abap-lab with npm install done, and an editor such as Visual Studio Code open on it. The tool npx abaplint comes with that install.

  • It helps to have written a first class, as in Your First ABAP Program, which also shows one abaplint finding. The words class, method and parameter are explained in Programming Concepts for Newcomers.

  • The lab already holds the finished files of this guide in modules/ROOT/examples/abap-lab/lint-demo/. Type them yourself rather than copying them. They live in their own folder, lint-demo, with their own configuration files, so the deliberate findings never appear when you run npm run lint or npm test of the lab.

  • The figures are drawings of the editor and the terminal, not screenshots. A highlighted box with a number marks the file or the lines of the step with the same number. A figure leaves out the three version lines (ABAP release, ABAP language version and the like) and the blank lines that the tool prints after Using config.

Steps

Map of the terminal workflow for ABAP without an SAP system with four numbered regions: npm install, the abaplint check, the transpile step and the run of the transpiled program

This map shows the whole terminal workflow of the ABAP lab: install the tools, check the code with abaplint, transpile it and run it. This guide works in the second region, the abaplint check.

Write the code to check

abaplint finds objects by the file layout of abapGit, as in the first guide: a class is a .clas.abap file with the source and a .clas.xml file with its attributes.

  1. In the lab folder, create the folder lint-demo with a folder src inside it, and in src the file lint-demo/src/zlint_claims.clas.abap. The class has one method, total, which adds up a table of amounts. The code runs, but it has habits that a style guide discourages: names with type prefixes (tt_, it_, ev_, lv_), a result returned through an EXPORTING parameter, a variable that is never used, a variable declared in advance, and a keyword written in lowercase.

    CLASS zlint_claims DEFINITION PUBLIC FINAL CREATE PUBLIC.
      PUBLIC SECTION.
        TYPES tt_amounts TYPE STANDARD TABLE OF i WITH EMPTY KEY.
        METHODS total
          IMPORTING it_amounts TYPE tt_amounts
          EXPORTING ev_total   TYPE i.
    ENDCLASS.
    
    CLASS zlint_claims IMPLEMENTATION.
      METHOD total.
        DATA lv_unused TYPE i.
        DATA lv_amount TYPE i.
    
        ev_total = 0.
        loop AT it_amounts INTO lv_amount.
          ev_total = ev_total + lv_amount.
        ENDLOOP.
      ENDMETHOD.
    ENDCLASS.
  2. Create the attribute file lint-demo/src/zlint_claims.clas.xml next to it:

    <?xml version="1.0" encoding="utf-8"?>
    <abapGit version="v1.0.0" serializer="LCL_OBJECT_CLAS" serializer_version="v1.0.0">
     <asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
      <asx:values>
       <VSEOCLASS>
        <CLSNAME>ZLINT_CLAIMS</CLSNAME>
        <LANGU>E</LANGU>
        <DESCRIPT>Claim totals</DESCRIPT>
        <STATE>1</STATE>
        <FIXPT>X</FIXPT>
        <UNICODE>X</UNICODE>
       </VSEOCLASS>
      </asx:values>
     </asx:abap>
    </abapGit>
    Visual Studio Code with the abap-lab project: the file lint-demo/src/zlint_claims.clas.abap is open and shows the class zlint_claims with its method total, which has an unused variable and a lowercase loop keyword; callout 1 marks the class file and callout 2 marks the companion XML file in the explorer

Run abaplint with a short configuration

abaplint runs only the rules named in its configuration file. A configuration without a rules section switches nothing on.

  1. Create lint-demo/abaplint-basic.json. The global section says where the ABAP files are: the pattern "/src/**/*.*" is relative to the folder of the configuration file, so it means every file under lint-demo/src. The syntax section names the ABAP release to check against (v758) and which names belong to your own code (errorNamespace). Each entry of rules is a rule key with true (switch on with the defaults) or with settings: keyword_case with the style upper wants keywords in capitals, and line_length allows 120 characters per line.

    {
      "global": {
        "files": "/src/**/*.*"
      },
      "syntax": {
        "version": "v758",
        "errorNamespace": "^(Z|Y|LCL_|TY_|LIF_)"
      },
      "rules": {
        "parser_error": true,
        "check_syntax": true,
        "unknown_types": true,
        "unused_variables": true,
        "keyword_case": { "style": "upper" },
        "line_length": { "length": 120 }
      }
    }
    Visual Studio Code with the file lint-demo/abaplint-basic.json open: the global files pattern, the syntax version and a rules section with six rules; callout 3 marks the configuration file in the explorer
  2. In the terminal, in the abap-lab folder, run abaplint and tell it which configuration to use:

    npx abaplint lint-demo/abaplint-basic.json
  3. Read the output. The tool prints its version and the configuration it used, then one line per finding, then a summary. A finding has the form file[line, column] - message (rule) [severity]. Here [11, 10] is line 11, column 10, where the name lv_unused starts. The rule key in brackets, unused_variables, is what to search for on the abaplint rules site, and [E] means error. The second finding is the keyword loop in lowercase, found by keyword_case. The other four rules of the file, parser_error, check_syntax, unknown_types and line_length, found nothing.

    lint-demo/src/zlint_claims.clas.abap[11, 10] - Variable "lv_unused" not used (unused_variables) [E]
    lint-demo/src/zlint_claims.clas.abap[15, 5]  - Keyword should be upper case: "loop" (keyword_case) [E]
    abaplint: 2 issue(s) found, 2 file(s) analyzed
    Terminal after npx abaplint lint-demo/abaplint-basic.json: abaplint prints two findings for the class, the unused variable lv_unused with the rule unused_variables and the lowercase loop with the rule keyword_case, then 2 issues found in 2 files; callout 4 marks the command and callout 5 marks the two findings

Add the Clean ABAP rules and read the findings

The first two findings are about plain tidiness. The Clean ABAP style guide asks for more, and abaplint has rules for several of its recommendations. The style guide names the checkers for its rules in its section How to Check Automatically.

  1. Create lint-demo/abaplint.json as a copy of the basic file with three more rules at the end: no_prefixes (Clean ABAP: avoid encodings, especially Hungarian notation and prefixes), prefer_returning_to_exporting (Clean ABAP: prefer RETURNING to EXPORTING) and prefer_inline (Clean ABAP: prefer inline to up-front declarations). The setting { "types": "^TY_|^TT_" } of no_prefixes is a regular expression for the type names whose prefix is reported, here ty_ and tt_.

    {
      "global": {
        "files": "/src/**/*.*"
      },
      "syntax": {
        "version": "v758",
        "errorNamespace": "^(Z|Y|LCL_|TY_|LIF_)"
      },
      "rules": {
        "parser_error": true,
        "check_syntax": true,
        "unknown_types": true,
        "unused_variables": true,
        "keyword_case": { "style": "upper" },
        "line_length": { "length": 120 },
        "no_prefixes": { "types": "^TY_|^TT_" },
        "prefer_returning_to_exporting": true,
        "prefer_inline": true
      }
    }
    Visual Studio Code with the file lint-demo/abaplint.json open: the same configuration as the basic one with three more rules, no_prefixes, prefer_returning_to_exporting and prefer_inline; callout 6 marks the configuration file in the explorer
  2. Run abaplint with the new file:

    npx abaplint lint-demo/abaplint.json
  3. Read the five findings. The two from before are still there, and three are new. no_prefixes reports the type name tt_amounts in line 3 (message: Avoid hungarian notation); in this run it did not report the prefixes it_, ev_ and lv_ of the other names, because this configuration sets only the types option. prefer_returning_to_exporting points at line 6, column 17, the parameter ev_total: the style guide prefers a method that returns its result with RETURNING, because the caller can then use the call inside an expression. prefer_inline points at line 12 and the variable lv_amount, which can be declared where it is first used.

    lint-demo/src/zlint_claims.clas.abap[3, 11]  - Avoid hungarian notation (no_prefixes) [E]
    lint-demo/src/zlint_claims.clas.abap[6, 17]  - Prefer RETURNING to EXPORTING (prefer_returning_to_exporting) [E]
    lint-demo/src/zlint_claims.clas.abap[11, 10] - Variable "lv_unused" not used (unused_variables) [E]
    lint-demo/src/zlint_claims.clas.abap[12, 10] - Prefer Inline Declarations, LV_AMOUNT (prefer_inline) [E]
    lint-demo/src/zlint_claims.clas.abap[15, 5]  - Keyword should be upper case: "loop" (keyword_case) [E]
    abaplint: 5 issue(s) found, 2 file(s) analyzed

    The rule keyword_case is a team rule, not a rule of Clean ABAP: the style guide gives no clear guidance on the case of keywords and asks teams to agree on one. This guide chose capitals, as the lab does.

    Terminal after npx abaplint lint-demo/abaplint.json: five findings with the rules no_prefixes, prefer_returning_to_exporting, unused_variables, prefer_inline and keyword_case, then 5 issues found in 2 files; callout 7 marks the command and callout 8 marks the five findings

Fix the findings

  1. Replace the content of lint-demo/src/zlint_claims.clas.abap with the fixed class below. Each finding has a fix: the type is now amounts and the parameters have names without prefixes (no_prefixes); total returns its result with RETURNING VALUE(result) and starts from the initial value zero, so the line ev_total = 0. is gone (prefer_returning_to_exporting); the unused variable is deleted (unused_variables); DATA(amount) declares the loop variable inline (prefer_inline); and LOOP is in capitals (keyword_case). Changing a method from EXPORTING to RETURNING changes how it is called, so in a real project you change every caller too; this lab class has none.

    CLASS zlint_claims DEFINITION PUBLIC FINAL CREATE PUBLIC.
      PUBLIC SECTION.
        TYPES amounts TYPE STANDARD TABLE OF i WITH EMPTY KEY.
        METHODS total
          IMPORTING claim_amounts TYPE amounts
          RETURNING VALUE(result) TYPE i.
    ENDCLASS.
    
    CLASS zlint_claims IMPLEMENTATION.
      METHOD total.
        LOOP AT claim_amounts INTO DATA(amount).
          result = result + amount.
        ENDLOOP.
      ENDMETHOD.
    ENDCLASS.
    Visual Studio Code with the file lint-demo/src/zlint_claims.clas.abap open after the fix: the type amounts, the method total with the importing parameter claim_amounts and a returning value result, and a LOOP AT with an inline declaration of amount; callout 9 marks the class file in the explorer
  2. Save the file and run the check again. Nothing is reported:

    npx abaplint lint-demo/abaplint.json
    abaplint: 0 issue(s) found, 2 file(s) analyzed

Check the result

npx abaplint lint-demo/abaplint.json prints abaplint: 0 issue(s) found, 2 file(s) analyzed. In a shell on macOS or Linux, echo $? right after the command prints 0 when there are no findings and 1 when there are some, which is what a build job checks to fail a build. The lab’s own npm run lint still prints abaplint: 0 issue(s) found, 10 file(s) analyzed, because its configuration reads only the folder src of the lab, and npm test still passes.

Variations

  • Switch on one more rule of the abaplint list, add its key to the rules section of lint-demo/abaplint.json with the value true and run again. Take the key from the abaplint rules page.

  • Put the flawed class back (from step 1) and change the style of keyword_case from upper to lower. The capitals of CLASS, PUBLIC, METHODS and the other keywords are now the findings, for example Keyword should be lower case: "CLASS" in line 1.

  • With the flawed class and the length setting of line_length changed from 120 to 40, three more findings appear, such as Reduce line length to max 40, currently 57 (line_length) for line 1.

What can go wrong

Symptom Cause Fix

generic[1, 1] - Error: No files found, lint-demo/source/**/*.* undefined (generic_error) [E] and 0 file(s) analyzed

The files pattern in the configuration points at a folder that does not exist (here /source/ instead of /src/). The pattern is relative to the folder of the configuration file. The command exits with code 2.

Correct the pattern in the global section, for example to "/src/**/*.*".

0 issue(s) found, 10 file(s) analyzed although the class has problems

You ran npx abaplint without a file name. It then reads abaplint.json of the lab folder, which checks the lab’s own src, not lint-demo.

Give the path: npx abaplint lint-demo/abaplint.json.

ERROR: Specified abaplint configuration file does not exist, using default config, then many findings in files you did not expect

The configuration file name is misspelled or its folder is wrong, so abaplint fell back to its default settings and checked the lab’s src folder with them. In this run it reported 20 findings and exited with code 1.

Check the path and the file name, for example lint-demo/abaplint.json.

One finding you expect is missing, and no message says why

A rule key in rules is misspelled (a run with keyword_cse instead of keyword_case reported four findings and none for the keyword). abaplint ignores a key it does not know.

Compare the key with the one on the abaplint rules page and with the key in the finding line.

0 issue(s) found and no rules seem to run

The configuration has no rules section (a file with only global was checked: 0 findings in 2 files).

Add the rules you want: the tool does not switch any on by itself.

Where abaplint fits next to ATC

On an SAP system, code is checked with the ABAP Test Cockpit (ATC), which runs check variants chosen by the system administrators, for example the checks for ABAP Cloud readiness, inside the system, with its knowledge of what is released there. abaplint works the other way round: it reads serialized source files in a folder or a Git repository, has its own rules with their own keys and settings, and needs no system. The same cycle applies to both: run the check, read the findings, fix or justify them, run again. Use abaplint for fast feedback while you write and in a build job; use ATC for the checks that need the system. The ATC checks cannot be run in the lab and are not shown here; read ATC and Code Inspector for how they work, and Coding Standards and Clean ABAP for the style guide behind the rules used above.

Where to go next