In this post, you will learn about cool features in Eclipse which will make life easier for ABAP developers.

Add Method Implementation

When you add a method definition Eclipse editor will start showing error as below.

Here, just hover the cursor over the the error icon and you will see the error – implementation is missing.

Now, click on the error icon, to get the options. These are called as ‘quick fix’ options. Double click on the option ‘Add implementation for instance_method’

The method implementation gets added where the method code can be added.

Rename Method

Suppose we have below code where a method orig_name is called from method instance_method.

"Definition
  METHODS : instance_method,
            orig_name.

"Implementation
  METHOD instance_method.
    orig_name(  ).
  ENDMETHOD.

  METHOD orig_name.
    IF 1 = 2.
      RETURN.
    ENDIF.
  ENDMETHOD.

Now, if you want to change the method name from orig_name to new_name, simply choose menu Source Code->Rename.

A pop up with current name is shown with option to change the name.

Give the name name and click Finish.

The method name is replaced at all places.

Method Extraction

This is another useful feature. Many times you write a code that is too big and later want to move some lines to another method and call the method.

Consider below code written in a method. The code won’t make any sense, but that is not the point.

  METHOD instance_method.
    IF 1 = 2.
      DATA(lv_value) = 1.
    ELSE.
      lv_value = 2.
    ENDIF.
  ENDMETHOD.

Let us move the code to new method and add a call to the new method using the menu option Source Code->Method Extraction.

Give the name for new method, you can make the method as static if needed, and select visibility.

Click Finish. Here, you can also click Next and check out the code that is going to be changed.

Method call, dentition and implementation is added automatically.

Method Call
Method Definition
Method Implementation

Another important aspect here is demonstrated below. If the code is such that you need parameters, the extract method feature will automatically add such parameters.

And incase you think you make a mistake, you can undo the changes with Undo (ctrl + z)

Unused Variables

This is a simple feature and removes unused variables from the selected block or from the entire class.

As the variables lv_one and lv_two were not used, they are deleted.

Format Block

This is a pretty printer feature but applied on selected line. Useful when you are working with code modification and do not want to touch earlier formatting.

The result of Format Block

F1 Help

F1 help is displayed in another window tiled with the editor window and not as a pop up window.

Element Information

F2 or menu path Source Code->Show Code Element Information will show the type of the code element.

From this screen, we can navigate to type further.

This will save lot of navigation time that is spent otherwise.

Method Information

Alt + F2 or Source Code->Show Method Information will show the method definition.

The navigation is allowed here as well, when composite types are used.

You have to love Eclipse editor for all these features, as these are designed to really make developers life easy. If you are still not convinced, hear this.

“When connection with SAP system breaks, unlike SAPGUI, Eclipse is not closed. It reconnects once connection is back and you don’t have to login again.

Visit ABAP on HANA series for Tutorials on CDS, AMDP, Eclipse, and ALV IDA.


If you like the content, please subscribe…

Join 4,017 other subscribers

Discovering ABAP YouTube Channel