This is a test message to test the length of the message box.
Login
|

051: ABAP Cleaner in VS Code - Installation and Guide

92

The ABAP Cleaner has been available for VS Code for some time now. Let's take a look at how to install it and use it in the ABAP Development Tools to save time and effort during development.

Advertising


Do you still want to manually format source code and make indentations these days, or should this be done automatically by a tool? What about your colleagues? Do you have completely different code styles within your codebase, and does someone break something as soon as they adjust the code and make their own formatting changes? For this, there's now the ABAP Cleaner, a simple tool to clean up the entire source code with the click of a button and ensure a uniform standard within a team. Therefore, in this article, we'll take a look at its installation and usage.

 

Installation

For the installation, we switch back to the Extensions section and search for ABAP Cleaner. There, we find the plugin via the SAP Standard Open Source Libraries. The installation page provides further information about the plugin, such as how code formatting is performed, which shortcuts are available, and how the various rules are defined. We install the tool in our environment using the Install button. Please note that this installs an executable file that requires Java to run. If you encounter problems with the Java installation, you will find further information on how to resolve this issue in the description.

Once the plugin is installed, we can see from the security warning that abap-cleaner.exe wants to be started. This is required for the ABAP Cleaner to run and perform the formatting. Therefore, we allow the executable file to run. Here you should ensure that this file is allowed within your company network and is not blocked by firewalls.

 

Formatter

When we start the ABAP Cleaner for the first time with Ctrl + 4, we are prompted to configure the default formatter for ABAP files. Clicking the "Configure" button opens a dialog where we can choose between the default formatters. The ABAP Cleaner is offered at the top, and directly below it is the default formatter from the ABAP Development Tools. This is the Pretty Printer. Since we want to use the ABAP Cleaner, we define this as the default formatter for ABAP files. The formatting is then performed directly, and we receive pre-formatted code. The ABAP Cleaner settings were directly imported from our Eclipse default settings, as we are already working with the tool there. In the next section, let's look at how we can configure further steps and set up the tool, for example, if this is our first time using it.

 

Interactive Mode

Pressing CTRL + SHIFT + 4 starts the plugin configuration. A new window opens, initially displaying a comparison of the current code with the already formatted code. All previously configured rules are applied. Here, we can also see which different rules have been applied to understand which formatting has been done. For example, if we select the entire source code in the `main` method, we see on the right-hand side the different rules that have been applied to this piece of code. This gives us complete control over how the source code is formatted, which rules are active, and how we can use them.

You can also find information in the settings above about the scope of the cleanup rule. Basically, you might want to clean up the entire class, which is what we have configured here. You can also define, for example, that only selected components are cleaned, or the current method we are using, to keep the scope of the cleanup smaller and also limit potential changes in the source code.

 

Configuration

Clicking the "Configure" button takes you to the settings, where you can create and manage one or more profiles and adjust various settings. It's generally a good idea to define a default profile that is shared and used within the team. You'll find various options for managing profiles at the top. On the left, you'll find all the rules that perform corresponding cleanups in the source code. Here you can see which rules you want to activate and which ones you might not need. When you select a rule, you'll find further settings and references, for example, to the official documentation to see why that rule is applied. Additionally, there's an example that illustrates how the actual rule is executed and how the processing works. With that, we'll leave the configuration for now and look at an example in our current source code.

 

Example

Let's look at the "main" method as an example. Here we have a method that we call first, and an unnecessary "ME" reference, since the method of the current class is generally called. In the loop, we've implemented a CHECK statement first. According to the Clean ABAP rule, the CHECK statement is no longer allowed after the first few statements. We could implement it if it were the first executable statement within the method, but not if there are already preceding statements. The CHECK statement also behaves differently depending on whether it's at the method level or, for example, within a loop. Therefore, we would restructure it. Then we call a method, where we have, for example, an EXPORTING statement. This EXPORTING statement is no longer necessary nowadays if we only have these parameters, as are the various spaces used for formatting.

If we now run the ABAP cleaner in detail, we see that unnecessary spaces have been removed. The "ME" reference was removed, the CHECK was resolved, the calculation of the sum was simplified since we can now use newer language constructs, and the output method was cleanly formatted and unnecessary keywords were removed. Overall, the method is now leaner and clearer.

 

Conclusion

The ABAP Cleaner has become a standard tool in ABAP development. It saves you a lot of time on formatting and gives you hints about unnecessary statements during development, automatically adds various things, restructures old statements, and even points out when variables are not used. This makes it an all-around tool for working with source code. If you're working in a team, you should definitely define a uniform style for the entire team or department so that the source code formatting always looks consistent and the next colleague doesn't overwrite the settings as soon as they've modified the source code. If you're not using the ABAP Cleaner yet, it's time to take a look and save a lot of time on source code formatting. The plugin is available for the ABAP Development Tools in Eclipse, but also for VS Code, as we saw today.

Thank you for watching and see you next time!

 

YouTube
Video


Included topics:
YouTubeScriptABAP CleanerVS CodeInstallation
Comments (0)



And further ...

Are you satisfied with the content of the article? We post new content in the ABAP area every Tuesday and Friday and irregularly in all other areas. Take a look at our tools and apps, we provide them free of charge.


052: 10 Minutes from Start to Launchpad

Category - YouTube

In this episode, we'll look at how we can create a RAP application within 10 minutes, generate and deploy it, and finally launch it in the Launchpad.

09/07/2026

050: Clean Core Measurement (Preview)

Category - YouTube

Want to make Clean Core KPIs visible? This overview gives you an insight into the current status of the open source project, its various functions and possibilities for creating transparency within your company.

08/03/2026

048: ABAP - ADT for VS Code (Part 4)

Category - YouTube

How do you get started with ABAP in Visual Studio Code? In this episode, we'll look at some examples in the Agentic AI and RAP environments. We'll also look at some points to keep in mind, when working with Agentic AI.

07/20/2026

047: ABAP - ADT for VS Code (Part 3)

Category - YouTube

How do you get started with ABAP in Visual Studio Code? In this episode, we configure Agentic UI and look at various examples of its use in the areas of ABAP Unit and RAP.

07/13/2026

046: ABAP - ADT for VS Code (Part 2)

Category - YouTube

How do you get started with ABAP in Visual Studio Code (VS Code)? In this session, we'll give you an overview of using the extension. We'll focus on creating new ABAP code, debugging, and testing.

07/06/2026