Programming

An Introduction to ABAP Development Tools

With the introduction of agile ABAP development, ABAP Development Tools has quickly become a popular and easy tool to use when programming with ABAP.

 

In the past, most likely, the Object Navigator (Transaction SE80) has served you just as faithfully as it has served other developers for many years. The Object Navigator is not only a stable development environment, but also one to which you have become accustomed, not least because of its form-based clarity.

 

However, the triumph of agile development has not left the Object Navigator unscathed. Although it can still keep up well with regard to ABAP Unit, it has been left behind for quite some time in terms of refactoring. What’s taken its place? ABAP Development Tools, formerly known as ABAP in Eclipse.

 

Let’s explore some beginning steps to take.

 

Creating a Project

With ABAP Development Tools, you can only develop a class within an ABAP project. The easiest way is to create an ABAP project based on a system connection that already exists in your SAP logon. More details on alternatives can be found in the help under Tasks > Fundamental Tasks and Tools > Working with ABAP Projects.

 

To create a new ABAP project, proceed as follows:

  • Start the creation of a new project using the menu path File > New > ABAP Project.
  • From the SAP logon entries displayed, select your development system and confirm it with Next.
  • Then you log on to the system as usual.

Creating a Product Class

If your product class (class for short) already exists, open it in ABAP Development Tools with the key combination (Ctrl)+(Shift)+(A). Just type a regular expression like "*CL*PROC*CH*CHECK*" into the Search field and select the class from the automatically generated list.

 

If your class does not yet exist, create it using the menu path File > New > ABAP Class. If your class is a subclass, you can specify the superclass at the same time. ABAP Development Tools then extends the definition accordingly.

 

ABAP Development Tools creates the local test include for your class automatically. You access this test include from the Test Classes tab below the ABAP source code editor window. If required, you can return to the definition and implementation of your class on the adjacent Global Class tab.

 

You can write your test class in the test include. Alternatively, you can first create a code template for test classes that you can reuse for other test classes in this and other test includes.

 

A code template is a code pattern that you can edit. If you enter a short name in the editor and the key combination (Ctrl)+(Space) for calling the code completion, the code template is offered to you for transfer into the source code. Alternatively, you can drag this code template from the Templates view and drop it into the editor window (see below).

 

The following steps are necessary to create a code template:

  1. Follow the menu path Window > Preferences > ABAP Development > Editors > Source Code Editors > ABAP Templates, and click the New button.
  2. For example, enter the short name “ltc” in the Name field and the description “Local Test Class” in the Description field.
  3. Enter the text from the listing below in the Pattern field and click the OK button.

ABAP Screen Template View

 

The following listing contains the following ABAP Development Tools variables:

  • ${enclosing_object}: Name of the product class
  • ${cursor}: Position of the cursor after all variables have been replaced
  • ${mut}: Name of the test class
  • ${cut_ref}: Reference of the object to be tested
  • ${cut_type}: Type of the object to be tested

 

CLASS ${ltc} DEFINITION FINAL

  FOR TESTING RISK LEVEL HARMLESS DURATION SHORT.

     PRIVATE SECTION

       METHODS setup.

       METHODS setup_ok FOR TESTING.

 

            DATA ${cut_ref} TYPE REF TO ${cut_type}.

     ENDCLASS.

 

     CLASS ${ltc} IMPLEMENTATION.

     METHOD setup.

       ${cut_ref} = ${enclosing_object}=>create( ${cursor} ).

     ENDMETHOD.

 

     METHOD setup_ok.

     Cl_abap_unit_assert=>assert_bound( ${cut_ref} ).

     ENDMETHOD.

ENDCLASS.

 

ABAP Development Tools helps you to replace the variables by marking the first variable in the code template. After you have renamed a variable and finished the renaming with the (Tab) key, it immediately jumps to the next variable. If you have used the ${cursor} variable in the code template, it then sets the cursor to the corresponding position in the transferred code (here in the method call of the CREATE creation method, which is not yet visible in the above figure due to the pending variable renaming).

 

Technical Documentation

ABAP Development Tools offers not only many useful functions, but also extensive help (menu path Help > Help Contents). In this blog post, we referred to and limited ourselves to the content of the SAP (On-Premise)—ABAP Development User Guide section. We therefore have shortened all the paths listed ahead by this root node.

 

If the descriptions in this post are not enough for you, you can find all the details in the SAP Help for ABAP Development Tools.

 

Below shows an excerpt of this special help content.

 

ABAP Screen Help Content (On Premise)

 

Conclusion

Being agile in your ABAP coding is an important skill, and ABAP Design Tools can help you accomplish this goal. This post introduced you to ADT and what it can do for you. Interested in more on coding with SAP and Eclipse? Check out this post on SAPUI5 and Eclipse.

 

Editor’s note: This post has been adapted from a section of the book Test-Driven Development with ABAP Objects by Winfried Schwarzmann.

Recommendation

Test-Driven Development with ABAP Objects
Test-Driven Development with ABAP Objects

Better, cleaner code—every developer’s dream. Test-driven development is how you’ll achieve it! From creating a robust test infrastructure to designing methods, classes, and packages that will stand the test of time, this book provides in-depth instructions for revitalizing your programming. Whether you’re writing new code or fixing legacy code, you’ll learn to select test cases, use test doubles, and generate test data. With information on agile methodology to round out the development process, you’ll have all the tools you need!

Learn More
SAP PRESS
by SAP PRESS

SAP PRESS is the world's leading SAP publisher, with books on ABAP, SAP S/4HANA, SAP CX, intelligent technologies, SAP Business Technology Platform, and more!

Comments