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: