Skip to Content
Author's profile photo Thomas Fiedler

Creating Exception Classes using Code Templates

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:


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:


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: 


Have fun.



Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Adam Krawczyk
      Adam Krawczyk

      Good tips, simple tricks - thank you 🙂

      Author's profile photo Hendrik Neumann
      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


      Author's profile photo Christian Drumm
      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.


      Author's profile photo Thomas Fiedler
      Thomas Fiedler
      Blog 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.