Skip to Content

With ABAP in Eclipse it is very easy to format the source code of  ABAP objects. Pressing Shift + F1 before saving or activating a development object gets your written source code in a pretty format.

But even though it is not a lot of work pressing two buttons before each saving or activation step I think to a certain degree this repetitive task should be automated. I do not worry about the time needed for this manual tasks but more about the situations where the unsteady source code formatting obfuscates the build-in version database or the abapGit history.

Pretty printer is cool, so why not perform it automatically? 

Therefore I added a functionality to ABAP in Eclipse to enable automatic source code formatting of ABAP objects (currently classes, function modules and CDS views are supported). The feature is part of the free abapCI Plugin.

One important characteristic of this feature is that it does not format all objects by default, but only that ones that start with a configurable starting source code comment. This comment is configurable and if not changed the default values to be added as first line of your development object are:

  •  “#autoformat … for classes, testclasses
  •  *#autoformat … for function modules
  • //#autoformat … for CDS views

In the Eclipse preferences there is the possibility to configure and even remove this mandatory comment. But I think this could lead to unwanted formatted development objects (eg. generated data provider classes, legacy source code items with a non SAP conform style,…). Thus I decided to take the defensive path by introducing the mandatory comment …  at least for the first release.

To get the automatic ABAP source code formatting feature up and running three steps are necessary.

1. Installing the abapCi Plugin from the Eclipse Marketplace, if not already done.

2. Enabling the corresponding checkbox in the Eclipse Preferences (Window->Preferences)

 

3. Adding the above mentioned comment as first line of the development objects which should be autoformatted when saved

Starting from this point it is ensured that on each save or activation of the development object the source code formatting is automatically performed.

Hope that helps to save at least some keystrokes or even better to clear up your abapGit or transport history.

Greetings, Andreas

To report this post you need to login first.

8 Comments

You must be Logged on to comment or reply to a post.

    1. Andreas Gautsch Post author

      Hi Marcel. The eclipse version seems to be ok. Have you installed the latest ADT?

      But lets take a closer look next week on the details of the errormessage. This week I am on vacancies without access to my personal computer.

      Greetings, Andreas

      (0) 
        1. Andreas Gautsch Post author

          Hmm, this error I see the first time, but well I am sure its solveable

          I made a new version today – 0.3.4, can you please update on this. If this does not solve your issue please post the stack trace of the error (should be in the error log or in the details) then I take a deeper look into this strange behaviour.

          (0) 

Leave a Reply