By choosing Eclipse as the development environment for ABAP, SAP has opted for open source software that is inherently open to extensions. This becomes particularly clear when you visit the Eclipse Marketplace. There you will find thousands of extensions that can significantly increase the functionality of Eclipse. Not only in relation to ABAP, but also for ABAP itself. These include, for example, the plugins “ABAP Favorites” by Lukasz Pegiel and “ABAP Code Search” by Ludwig Stockbauer-Muhr.
In addition to the option of integrating self-programmed plugins into Eclipse, the standard version also includes the function of “External Tools”. These can be used, for example, to start programs and scripts on the system on which Eclipse is also running. All that is required is a configuration, no programming. This makes setup quick and easy.
In this blog, we want to take a look at an example of how to configure and use such an external tool.
Use case “Translation”
For historical reasons, there are many German comments in ABAP sources. These often contain helpful information that every developer should have access to, for example when debugging. However, German is not as widely spoken as English, for example.
For this reason, the use of English comments is a good approach. This makes sense because, on the one hand, ABAP itself consists of English syntax, which ensures consistency when reading. On the other hand, people from different countries now work on many projects. Using a globally spoken language such as English gives everyone the opportunity to read the comments.
Therefore a translation aid from German to English and vice versa would be helpful in Eclipse. Surprisingly, I couldn’t find a standard function for this right away. I couldn’t find a plugin for it in the Eclipse Marketplace either.
So what’s the use case for this blog? We build the function ourselves with the help of External Tools by integrating Google Translate context-sensitively via an internet browser.
In practice, this configuration shouldn’t be used without further consideration. It would be important to clarify in advance what Google Translate will do with the input. It might, for example, save it for the purpose of training your translation skills. This is certainly not desirable with comments from company-specific ABAP applications.
Configure External Tools
In Eclipse, the last entry in the “Run” menu is “External Tools.” This is a submenu from which you can select the entry “External Tools Configuration…”.
Use the “New launch configuration” function to create a new configuration. The name could be “Translate DE, EN” for example.
I used “${system_path:chromium}” as the location. This is how Eclipse starts the Chromium internet browser in my Ubuntu Linux. In Windows, the call for Microsoft Edge or Google Chrome must be adjusted accordingly.
Chromium accepts parameters when called. I assume that this is also possible with Chrome and Edge. A parameter can be a URL, for example, which is then displayed directly. The transfer of this parameter from Eclipse is set as an argument in “Arguments”. I used the following setting: “https://translate.google.com/?sl=de&tl=en&text=”${selected_text}“&op=translate”.
The use of the variable “${selected_text}”, which Eclipse provides, is interesting. This makes the call context-sensitive, i.e. the currently selected text is passed to Chromium as an argument.
Those were the necessary settings.
Using External Tools
Using the configuration is easy. First, you need to select a German comment in the ABAP source code and then select the name of the configuration in the “Run” menu, submenu “External Tools”. In my case, this is “Translate DE, EN”. Google Translate will then open in your internet browser. The German comment is on the left and the English translation is on the right.
Incidentally, you can avoid selecting the “Run” menu because there is an icon for the External Tools in the icon list. This makes it a little easier to use.
Key binding is also possible via the “Window→Preferences” menu. Select the “General→Keys” entry there. The command is “Run Last Launched External Tool” which you can assign to a function key such as F12. Unfortunately, this only allows you to run the last configuration used. But that’s better than nothing.
Summary
The example of using External Tools in Eclipse shows that it only takes a few steps to launch another application from Eclipse in a context-sensitive manner. The technology is part of the Eclipse standard, so it does not require any additional plug-ins.
One final note: There is a GitHub Copilot plugin for Eclipse. Among other things, Copilot can also translate. All you have to do is copy and paste the German comment with a request to translate it into English.
Thank you for reading. If you enjoyed the post, please share the article with your community. Thanks in advance.
Michael (a mind forever voyaging)
