ABAP cleaner Eclipse plugin

The ABAP cleaner Eclipse plugin is a great tool to clean up your ABAP code according to the ABAP clean code principles.

Questions that will be answered in this blog are:

  • How to install the ABAP cleaner Eclipse plugin?
  • How to run the ABAP cleaner?
  • How to configure the ABAP cleaner?

Installation of the ABAP cleaner Eclipse plugin

Follow the instructions on the ABAP cleaner site for installation. In short, just like you install the ADT tools, now put in the site “https://sap.github.io/abap-cleaner/updatesite“. Download the software and ignore the certificate warnings. Eclipse restart is required.

Running ABAP cleaner

Basic use instructions can be found on the ABAP cleaner site. We will use this example code:

REPORT zcleanerdemo.

* ABAP clean code demo
Data: abap_true type boolean.
data: do_not_do_anything type boolean.

write:/ 'Hello world'.

if abap_true <> 'X'.
write: 'ok'.
else.
write: 'not ok'.

endif.

Yes, this code is ugly.

In Eclipse right click on the code and select the option Source Code and then the option Clean up with Interactive ABAP cleaner…

It is best to start always with the interactive cleaner so you have insights and control on the changes done to your source code.

On the left hand side you see your old code. On the middle the code changes proposed. On the right hand side you see the clean up settings.

The profile is determining the rules used. Out of the box you get the default and essential profile. It is advised to play around and build your own set using the Configure button (see next chapter in this blog).

You can set the clean up range: from current statement, current method, current class to whatever code you opened in Eclipse (multiple windows). You might wonder, why only current statement or method? Remember one of the clean code principles is the boy scout rule; leave the code better than how you found it. So no need to refactor old stuff completely, do it chunk by chunk every time.

The restrict rules of syntax can be set to the latest ABAP release or to a specific release.

If you click on a rule, you can see the rules applied in bottom right part of the screen:

If you are happy with the changes press the Apply and close button.

ABAP cleaner configuration

On the screen above when you hit the Configure button you reach the configuration screen:

This screen is overwhelming when you start. Top right you can manage your profiles. Create new ones or copy from templates. Bottom right you can switch on and off which detailed rule is part of the profile. On the top right you can fine tune the exact details of each rule according to your needs and preferences.

The changes you make will be made instantly available on the example, so you can immediately assess the impact of your fine tuning.

Word of care: take care that ABAP cleaner and Pretty printer are not constantly juggling your code around.

Installing ADT Eclipse frontend

This blog will explain the installation of the ABAP development tools (ADT) on the laptop or workstation.

Activation of the ABAP development tools needed on the backend is explained in this blog.

Questions that will be answered in this blog are:

  • Where can I find the software downloads?
  • Which Java version do I need?
  • What is the installation sequence?

Java version

As of February 2021 Java version 11 is mandatory. See OSS note 2949356 – Java 11 is mandatory for ADT in February 2021.

Software download of ADT tools

Software can be downloaded from the SAP public site: https://tools.hana.ondemand.com/ .

Click on the ABAP part:

Download here the Eclipse version needed and check carefully the JAVA instructions. Pending on your local system a JAVA JRE might already be there or forbidden by your windows administrators. Check note 3035242 – Remove bundled JRE from Eclipse packages if needed.

Installation

Make a directory on your local machine called C:\ADT\.

Do not use spaces and special characters in the installation directory. This is a main cause of issues. 

Extract the files:

Now in the the directory Eclipse, you can launch Eclipse by double clicking on the executable:

This will now launch Eclipse. If this works ok, skip the launch issue below and proceed to Installation inside Eclipse.

Launch issue

Depending on your JAVA installation and settings a Eclipse launch code might appear:

If this happens, most likely Eclipse can’t find a proper JAVA installation. In the previous step you have downloaded the SAP JVM files and extract them as well to the C:\ADT\ folder.

Now we need to edit the Eclipse.ini file:

Edit the file and add the line to point to the SAP JVM:

-VM

C:/ADT/sapjvm_8/bin/javaw.exe

This has to be inserted at exactly the designated spot. Save the file and re-launch Eclipse.

Installation inside Eclipse

After first initial launch of Eclipse:

  1. In Eclipse, choose in the menu bar Help > Install New Software…
  2. Add the URL https://tools.hana.ondemand.com/latest

After this install is done Eclipse needs to restart.

Now you can open the ABAP perspective in Eclipse:

ABAP Eclipse OSS notes

There might be bugs in Eclipse. In SAP OSS search for component BC-DWB-AIE to find bug fixes or explanations on specific functions.

Or look for the search term “quick fix” to find bug fix notes for the Eclipse quick fix function.

Clean ABAP Eclipse plug-in: ABAP cleaner

To speed up clean ABAP in practice, you can install the clean ABAP cleaner plug-in for Eclipse. Read this blog on how to do this.

Enabling ABAP backend for ABAP Eclipse

This blog will explain the actions you need to perform to enable an ABAP backend for ABAP Eclipse tools (ADT = ABAP Development Tools).

Questions that will be answered are:

  • How to enable ABAP backend for ABAP Eclipse?
  • Where to find more background information on ADT (ABAP Development Tools)

For the installation of the front end tool ABAP Eclipse (ADT tools) read this blog.

Background information

The up-to-date information on the ABAP Development Tools and how to install ABAP Eclipse with the correct versions can be found on the SAP site. This site contains on the ABAP tab also the most up-to-date manual on the backend configuration.

The section below will describe the main steps.

Enabling ABAP backend for ABAP Eclipse

In transaction SICF enable node ADT:

Also activate the ABAP documentation tool nodes:

If not yet active, also activate SICF node wdy_aie_vd_preview.

Now start to test ABAP in Eclipse. Pending on the authorizations it might already work. If it does not work, check the standard SAP manual on the required RFC authorizations you need as ABAP developer to run ABAP in Eclipse.

In the manual you will read about SFW5 switch SRIS_SOURCE_SEARCH. Be very careful to switch this on. It is very resource intensive and there is limited added value.

Bug fix OSS notes

There might be bugs in Eclipse backend code. In SAP OSS search for component BC-DWB-AIE.