Skip to Content

Maybe you already asked yourself how to create an exception class with the ABAP development tools in eclipse without having the exception builder for generating the exception IDs. In this blog you will see how the code templates in eclipse become your friend:

Creating an exception class in eclipse is done via the class creation wizard (CTRL+N) just by adding an already existing exception class as the superclass:

/wp-content/uploads/2013/05/cx1_216999.png

The tool creates the new class in the repository and automatically generates the constructor into the source code. The newly created class will be opened in as a new editor tab in eclipse.

Now you want to add an exception ID to the class in order to assign a message to your excption class.

For that the IDE provides you with an ABAP specific code template that you find in the eclipse template gallery (Menu Window->ShowView->Templates)

You can pick this template in the source code editor just by typing the name of the template and using the code completion:

/wp-content/uploads/2013/05/cx2_217000.png 

The preview in the yellow box beside the template gives you a hint what happens when you choose the template.

After choosing the template via pressing ENTER the editor generates the code of the exception ID into your exception class.

Now you can enter the message class ID and message number of your choice. Ideally you open the message class in the eclipse-based message class editor for your convenience: 

/wp-content/uploads/2013/05/cx3_217007.png

Have fun.

Regards,

Thomas.

To report this post you need to login first.

4 Comments

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

  1. Hendrik Neumann

    hi Thomas,

    thanks for another good eclipse how to!

    Somehow it’s much more fun to use template in eclipse than in SE80. Comes more naturally and is much better integrated in the flow of work. I think there might still be lot of potential for further use cases…

    Viele Grüße

    Hendrik

    (0) 
  2. Christian Drumm

    Hi Thomas,

    usually when working with exception classes i use OTR-based text elements. Is there any way to edit these text elements via eclipse as well. Currently my workflow involves switching to the SAP GUI in order to create the necessary texts.

    Christian

    (0) 
    1. Thomas Fiedler Post author

      Hi Christian,

      currently there is no possibility in eclipse to maintain the OTR Texts of an exception class. Our recommenadation is to use message-class based exception classes so the support for OTR texts has not the highest prio for us. But I see a chance to provide this as the Web Dynpro Tools also using OTR texts and they have already a solution in eclipse. Hope we can reuse parts of it.

      Regards,

      Thomas.  

      (0) 

Leave a Reply