You create global exception classes in the Class Builder.
You can create a new exception class where you need it the first time, for example when assigning exceptions in the method definition. See also: Creating Exceptions for Methods.
To create an exception class from the initial screen of the Class Builder SE24:
...
1. Enter the name of the new class according to the naming conventions under Object type. The prefix CX is added to the class name of all exception classes.
2. Choose Create.
The Create Class <Name> dialog box is displayed.
3. Enter the rest of the basic data for the class:
- Inherits from
Enter the name of the direct superclass.
Exception classes are derived from one of the predefined basic classes CX_STATIC_CHECK, CX_DYNAMIC_CHECK or CX_NO_CHECK as subclasses. Depending on the position of the exception class within the class hierarchy, enter the appropriate class within this hierarchy or one of the predefined basic classes as superclass. In the latter case, expand a new hierarchy tree.
- Description
Enter a short text as description for the new class.
- Inst. Creation
In general,
classes are marked with the Public
option. This means that each user can create instances of the particular class
(with CREATE OBJECT).
The Protected option defines that
only inherited classes or the relevant class itself can create instances of
this class.
If you choose the Private option,
only the relevant class itself can create its instances (only using its own
method).
You can define an abstract class with the Abstract option. You cannot create an
instance for this class. An abstract class can be used as template for your
subclasses. You can only access this class with your static attributes or with
your subclasses.
- Class type
If you assigned the prefix CX for the name of the exception class, class type Exception class is already selected. At this point, you can decide whether the texts for your newly created exception class should be recreated and stored in the OTR, or whether you want use existing message classes for this exception class.
Within an exception class you have to decide between text management in the OTR, or using message classes. It is not possible to use both text variants in an exception class.
If you have decided to use message classes, set the With Message Class on the Creation dialog.
- Final
You define a
final exception class with the Final
option. This class completes the inheritance hierarchy since a final class may
not create any further subclasses.
- Modeled only
If you mark this checkbox, no entry is made in the class pool for this exception class. This class cannot be accessed at runtime.
4. Choose Save.
The system displays the Object Directory Entry dialog box.
5. Enter the name of the Package.
6. Choose Save again.
You create a new exception class. A class pool was generated for the new class if the Modeled only option was not activated.
In contrast to normal classes, you cannot create a method for an exception class. The Class Builder simply creates the constructor. However, you can create attributes and maintain exception texts.
Creating Attributes for Exception Classes