Application Development Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 
ceedee666
Active Contributor
9,184

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.

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

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:

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.

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.

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.

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.

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

16 Comments
Labels in this area