Skip to Content

A very useful feature in ABAP development is the possibility to create a new method from the editor via the form-based method generation wizard. Here I will show you how you can do that with ABAP in Eclipse:

So let’s assume you are in the editor implementing your ABAP code in a class method.

Now you recognize that you need a new method that you want to call within your created code.

You can now navigate to the definition part of the class to add the method signature, implement the method and navigate back to the call position of the newly created method. That’s a bit cumbersome, isn’t it. 😕

Why not do the following:

You can create the new method by just typing the name of the non-existing method in the editor and use the Quick Fix functionality. You do this just via pressing CTRL-1 when the cursor is positioned on the method name:

/wp-content/uploads/2013/03/editor_192017.png

   

On the upcoming Quick Fix popup you choose the option Create method ….

The editor now opens a wizard to define the signature of the new method:

/wp-content/uploads/2013/03/qf_192018.png

 

You can now specify the most relevant details of the method like visibility, access scope and the name.

In addition you can specify the parameters of the method via the table control. You can define whether you need importing, exporting, changing or returning parameter and you can specify the parameter type with very nice value help in the editor cell. 

/wp-content/uploads/2013/03/edit_2_192059.png

   

 

When you are ready with the declaration you press Finish and you’re done.

The editor now automatically generates out of this information the method declaration and the method implementation:

/wp-content/uploads/2013/03/edit3_192060.png

You can now directly go ahead with your implementation.

Kind Regards,

Thomas.

To report this post you need to login first.

7 Comments

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

  1. Hendrik Brandes

    Hello Thomas,

    thank you for showing this. For me as an SE80-fanatic, it has been(and still sometimes is) hard to move to AiE. Especially, I like (…) the form-based class builder, because it/he makes the declarations for me;-)

    But: The key-features of the Eclipse-platform prevail the the effort for an experience developer to move from SE80 to AiE. Hopefully, more and more features are implemented! 

    Say a “Well done” to all members of the AiE-Team!

    Kind regards,

    Hendrik

    (0) 
  2. Adam Krawczyk

    Hi Thomas,

    Nice blog, thank you.

    I recommend to use this approach (CTRL + 1 method for method wizzard) also for unit tests, it is really simple to create new test case methods.

    Another useful feature here is types autosuggestion. So if you have types declaration before call:

    DATA l_carrid TYPE s_carrid.

    DATA l_connid TYPE s_conn_id.

    And enter new method name that does not exists yet:

    reserve_booking( i_carrid = l_carrid i_connid = l_connid ).

    wizard will automatically suggest these variables. That allows developer to write code even more efficiently and that is the power of AiE.

    Regards 🙂

    Adam

    (0) 
  3. Luís Pérez Grau

    Hi Thomas,

    Is possible that quick fix doesn’t work for global classes in 7.3 release?

    It gives me the following error:

    Invalid XML format of the response. Usually this is a programming error, but occasionally this is caused by an outdated client. Details: Value ” is not legal. (platform:/resource/project/emfresource.extractmethodrefactoring, 1, 715)

    Thanks!

    Luis

    (0) 
    1. Thomas Fiedler Post author

      Hi Luis,

      I have checked it with ADT 2.7 against NW 7.31 SP7 and it worked.

      Which version combination do you have?

      Regards,

      Thomas.

      (0) 

Leave a Reply