Editing Abap code with Notepad++
Maybe like me, you are doing some remote work with using RDP connections or Citrix. It can be very slow sometimes even if you tweak the settings of your RDP connection or Citrix by putting an awkward 8 bit resolution, something unheard in the first quarter of the twenty first century... I often experience lags and slowdown that makes me sometimes very angry. Using a SAP logon connection through RDP can be a very frustrating experience (especially if you are in China like me...)
I could use the Abap editor on the Eclipse IDE but Eclipse is very greedy in term of resource and the editor seems to require a SAP connection that I cannot have with my current network settings (RDP through a VPN connection)
As a workaround, I often copy the code of a report, do modifications on my workstation and paste the code in the SE80 transaction which is the fastest way I have found so far...
I often use the application Notepad++ for text edition. It is a versatile editor written in C++ that you can find on this website:
https://notepad-plus-plus.org/. It has many interesting features and plugins and is quite easy to extend.
It is based on the Scintilla editor. I will not describe the features and plugins but it is a very good editor and it is free (GPL licence). I use it to edit Java code, Python Code XSLT, XML, and sometimes binary files. It can encode or decode base64 without using something else.
I also use it to edit Abap code, however, I do not have syntax highlighting or code folding. Abap is not a recognized language. I was tired to read code in the same black colour font so I decided to write an Abap syntax highlighter for this editor.
First, you need to open the menu item "define your language":
You can see that the editor already accept quite a number of languages, but no Abap…
On the first screen, let's define some keywords…
The list of keyword was simply retrieved on SAP help index and with a bit of regex and find/replace, I was able to have them all (I suppose) All keywords are separated by space. Use the styler to set a font and its related size and color:
I defined how comments should be highlighted:
I allow folding of comment and as you know, comments can be placed anywhere in Abap… A comment can begin with " or & and stop with a carriage return or "
I set also a style for operators and delimiters:
In the end, I set some code folding:
Once done, I was able to see my code with highlight and folding. The whole syntax definition took me only a couple of hours.
This is an example of report without syntax highlighting and code folding:
Once I select my Abap syntax highlighter, this is what my code looks like:
Example of a module function call:
Here an example of code folding for a try catch block:
The results were already quite impressive with little work. Even if sometimes it has some errors (erratic code folding most of the time or variables recognized as keywords) I hope next time to be able to create plugins to have for example a basic pretty printer and maybe an automated code beautifier ( with my very tight schedule, it will be very hard…)
You can find in the references the settings of the syntax highlighter and see by yourself. Use the button "Import" in the define Language tool:
You can play around and see what settings give the best results!
References:
Notepad++ website:
https://notepad-plus-plus.org/
The UDL for Abap:
Abap UDL file
The UDL website:
http://udl20.weebly.com/