Skip to Content

Introduction

In my point of view the release of the SDK for the ABAP development tools (cf. First version: SDK for ABAP development tools) was a major change to the way SAP provides developer tools. For the first time it is possible to easily extend the development environment provided by SAP. Therefore, the SDK enables developers to enhance the development environment with new functionality or missing features.

One feature that is missing in the the SE80 as well as in the ABAP development tools is an simple way to create transports of copies. While the usage of transports of copies is recommended e.g. by the German SAP User Group (DSAG) in its development best practices guide line (cf. Andreas Wiegensteins blog DSAG Best Practice Guideline for ABAP Development now available in English), creating transports of copies is quite cumbersome. As a consequence custom transactions or reports are usually used to simplify the creation of transports of copies. While such a report simplifies the creation of transports of copies it is not integrated into the development environment. consequently, the usability is far from perfect.

In this blog series I’ll show how I extended the transport organizer view of the ABAP development tools. The plug-in that I’ve developed enable the creation of a transport of copies with just one click. The blog series consist of three parts. In the first one I’ll explain the eclipse side of the plug-in, in the second part (Creating a ABAP in Eclipse plug-in using the ADT SDK – Part 2) the ABAP side. The third part will focus on releasing the plugin using github. The idea behind this blog series is twofold. First, I want to provide an overview of what is necessary in order to create a ABAP development tool plug-in that invokes some back end functionality. Second, I hope to encourage other developers to create and release useful enhancements for the ABAP development tools. Consequently the complete source code of the plug-in is available at ceedee666/adt_transport_utils_plugin · GitHub.

Getting Started

If you are not yet familiar with the SDK for the ABAP development tools I would recommend the following documents and blogs. The two blogs Starting with ADT SDK is easy – Pt.1 and Starting with ADT SDK is easy – create your own transaction launcher (Pt.2) by SAP mentor Martin Steinberg provide a nice starting point. In addition to that the excellent document NetWeaver How-To Guide: SDK for the ABAP Development Tools by Wolfgang Woehrle provides a full tutorial including the development and invocation of back end functionality.

Developing the Eclipse Plug-In

As Martin Steinberg already has described hot to create a simple eclipse plug-in I will skip this step and start with the necessary configuration of the the plug-in project. In order to use the SDK some ABAP development tools plug-ins need to be added to the list of required plug-ins. This is done by editing the plugin.xml file.

2014-08-26 22_12_32-ABAP - adt_transport_utils_plugin_plugin.xml - Eclipse.png

After opening the plugin.xml file in the editor, the required plug-ins can be added in the dependencies tab.

2014-08-26 22_13_04-ABAP - adt_transport_utils_plugin_plugin.xml - Eclipse.png

Unfortunately there is currently no documentation available which plug-in contains which classes. So finding the correct plug-in to add to required plug-ins list is sometimes quite challenging. Furthermore, the plug-ins are provided by SAP without the plug-in source code. This makes understanding the usage of some methods as well as debugging quite difficult. Hopefully, SAP will address these two issues in future releases of the SDK.

Extending the Transport Organizer View

The next step is to extend the transport organizer view with the menu entries to create the transport of copies. I wanted to add two feature to the transport organizer view:

  1. the possibility to create a transport of copies based on existing transport request
  2. the possibility to create and directly release a transport of copies based on en existing request.

To provide this functionality, I created the menu entries shown in the following screen shot:

2014-08-26 22_25_51-ABAP - adt_transport_utils_plugin_plugin.xml - Eclipse.png

The eclipse RCP enable the extension of views and menus using extension points. In order to extend the menu of the transport organizer view it is first necessary to identify the appropriate extension point. This can be done using the eclipse plug-in spy. By pressing <ATL>+<SHIFT>+<F1> the plug-in spy shows information regarding the current view. The information provided by the plug-in spy are shown in the following screenshot. In order to extend the menu of the transport organizer view the information regarding the active menu contribution identifier, in this case com.sap.adt.tm.ui.tmview, is important.

2014-08-27 07_39_06-ABAP - adt_transport_utils_plugin_plugin.xml - Eclipse.png

In order to extend the popup menu of the transport organizer view a menu extension (extension point org.eclipse.ui.menus) needs to be added to the “Extensions” section of the plugin.xml file. The easiest way to add an extension is to use the “Extensions Wizards”. These wizards can be started by clicking on the “Add” button in the extensions tab. In order to create the menu items shown above I added a menu contribution consisting of a menu and two commands to the extension point.

2014-08-27 07_59_14-ABAP - adt_transport_utils_plugin_plugin.xml - Eclipse.png

Furthermore, I created a icon for each of the menu and the commands. The icons are located in the icons folder in the plug-in project. To add an icon to a menu or command is simply done using the “Browse…” button next to the icon element in the “Extension Element Details” part of the editor. Finally, I also externalized the strings like label and tooltip to allow for late internationalization of the plug-in. This can easily be done by right clicking on an extension element and selecting “Externalize strings” in the popup menu. This will create a folder named OSGI-INF in the plug-in project. The folder contains a file named bundle.properties that contains the externalized strings.

Implementing the Menu Command Handlers

The next step is to implement the command handlers underlying the menu entries. Command handlers are created by extending the extension point org.eclipse.ui.handlers. The link between a command and a handler is created via the commandID. In the screenshot above the command “Create Transport of Copies” is linked to the commandID adt_transport_utils_plugin.commands.createAndRelease. The command itself is implemented by a class de.drumm.adt_transport_utils.ui.CreateAndReleaseTransportOfCopiesHandler.

Furthermore, a expression is linked to each command specifying when the command is enabled. In this example the commands are only enabled when only one item is selected an the item in a subclass of com.sap.adt.tm.IRequest. The expressions are defined using the Command Core Expressions. A details explanation of Command Core Expressions is beyond the scope of this blog post. A detailed explanation of Command Core Expressions is available at Command Core Expressions – Eclipsepedia.

2014-08-27 10_53_44-ABAP - adt_transport_utils_plugin_plugin.xml - Eclipse.png

The handler class for a command is implemented by inheriting from org.eclipse.core.commands.AbstractHandler and implementing the execute method. The following code snippet shows the complete code of the CreateAndReleaseTransportOfCopiesHandler class. In the execute method the current selection is read from the active window. Using this information an instance of the TransportOfCopiesRequest class is created and the its executePost method is invoked.


public class CreateAndReleaseTransportOfCopiesHandler extends AbstractHandler {
    public CreateAndReleaseTransportOfCopiesHandler() {
    }
    public Object execute(ExecutionEvent event) throws ExecutionException {
        IWorkbenchWindow window = HandlerUtil
                .getActiveWorkbenchWindowChecked(event);
        ITreeSelection selection = (ITreeSelection) window
                .getSelectionService().getSelection();
        new TransportOfCopiesRequest(window, selection, true).executePost();
        return null;
    }
}





The executePost method is shown in the next code snippet. In the method first the destination of the ABAP project is read. Next, the getResourceUri method uses teh discovery service provided by the ABAP development tools SDK to get the URI of the back end service implementation. Finally, the post method of this URI is invoked.


public void executePost() {
        String destination = this.getAbapProjectDestination();
        URI tocResourceUri = this.getResourceUri(destination);
        if (tocResourceUri != null) {
            this.executePost(destination, tocResourceUri);
        } else {
            MessageDialog.openError(this.window.getShell(),
                    "ADT Transport Utils Error",
                    "Necessary backend resource could not be found. ");
        }
    }




In the getRessourceUri method the discovery service is instantiated wit a DISCOVERY_URI (in this case /ztransportutils/discovery). Next the discovery service is used to get an instance of IAdtDiscoveryCollectionMember using the TOC_RESOURCE_SCHEME (http://www.drumm.de/transportutils) and the TOC_TERM (create_toc). These strings will be relevant when implementing the discoverable resource in the backend as they provide the connection between the discovery service and the concrete service implementation.


private URI getResourceUri(String destination) {
        IAdtDiscovery discovery = AdtDiscoveryFactory.createDiscovery(
                destination,
                URI.create(IAdtTransportUtilsConstants.DISCOVERY_URI));
        IAdtDiscoveryCollectionMember collectionMember = discovery
                .getCollectionMember(
                        IAdtTransportUtilsConstants.TOC_RESOURCE_SCHEME,
                        IAdtTransportUtilsConstants.TOC_TERM,
                        new NullProgressMonitor());
        if (collectionMember == null) {
            return null;
        } else {
            return collectionMember.getUri();
        }
}



The executePost method is quite simple. It adds the ID of the selected transport request and if the transport of copies shall be released immediately as query parameters and executes the post method. The remainder of the executePost method then mainly consists of error handling.

Plug-in Build Parameters & Testing

The last thing that is necessary to complete the implementation of the eclipse part of the plug-in is to adjust the build parameters. Here it is necessary to add the icons folder to set of folders that need to be included in the binary build. This is done on the build tab of the plugin.xml file. While this isn’t required to test the plug-in in the development environment it is required to create a fully functional release of the plug-in afterwards.

2014-08-27 22_12_24-ABAP - adt_transport_utils_plugin_plugin.xml - Eclipse.png

With the build parameters set up correctly it is now possible to perform a fist test of the plug in. The easiest way to do this is to right-click on the plug-in project an select Run as -> Eclipse application. This will start a new eclipse instance including the new plug-in.

Summary

The completion of the eclipse plug-in concludes the first part of the blog series. If you want to have a detailed lock on the source code of the plug-in itself, the easiest way is to use the Import -> Projects from Git wizard in eclipse to simply clone the git repository (ceedee666/adt_transport_utils_plugin · GitHub).

If you only want to try out the plug-in, there is also a brief description of the installation procedure for the plug-in (for both, the eclipse and the ABAP part) available on the GitHup repository.

Christian

To report this post you need to login first.

8 Comments

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

    1. Christian Drumm Post author

      Hi Wolfgang,

      thanks for the feedback. You should also have a look at the second part. The implementation of the ABAP side was the part that proved most difficult for me. Now that I know how to do it, I was able to understand your document much better ๐Ÿ˜‰

      Christian

      (0) 
      1. Wolfgang Woehrle

        Hi Christian

        Thanks for your feedback. I would be happy to get more details from you, what needs to be made more understandable in the second part. Which information did you miss?

        I look forward to hearing from you.

        Kind regards,

        Wolfgang

        (0) 
        1. Markus Theilen

          Hi Wolfgang!

          I am also going through your document and also Christian’s blog about the ABAP part of his plugin. I have to admit that I still do not get the whole picture. This will be my personal fault but I would love to know why I have to implement this BAdI and that Ressource App.

          Is there a new version of your tutorial available or is there some other document to guide someone through the first necessary steps?

          Thanks!

          (0) 
          1. Wolfgang Woehrle

            Hi Markus

            Thank you for your feedback.

            Just to go for sure: Did you find the following document? http://scn.sap.com/docs/DOC-40668 There are many links in this blog. So, you might could have overseen it.

            In this document, see above, there are overviews in chapter 1.1 and 1.7 -> What information would you also like to see here?

            Regarding BAdi and Ressource App: Please see chapter 1.6., 2.3, and 2.3.3.

            Don´t hesitate to contact me if you have further questions. Thank you.

            Kind regards,

            Wolfgang

            (0) 
  1. Tim Jรถrgen

    Hi, thanks for this tutorial. I am currently working together with Markus Theilen on a plugin and we just managed to get the ADT SDK running. However there seems to be a problem with out launch configuration and we get an out of memory exception from time to time, as we start the new Eclipse application with the ADT plugins enabled. But currently I can’t yet narrow down the problem to post a bug report ๐Ÿ™ . But I keep in searching.

    Thanks again!

    (0) 
      1. Markus Theilen

        Hi Wolfgang!

        Thank you for your support! We finally managed to get what we wanted, but it took some time ti wrap my brain around the SDK and the tutorial. On Wednesday or Thursday I will probably meet with Thomas Fiedler to talk about the little plugin we did. I will try to make my difficulties speakable to that time. ๐Ÿ™‚

        Thanks, Markus

        (0) 

Leave a Reply