Entering content frameProcedure documentation Creating Exception Classes Locate the document in its SAP Library structure

Use

You create global exception classes in the Class Builder.

Procedure

Note

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.
  3. The Create Class <Name> dialog box is displayed.

  4. Enter the rest of the basic data for the class:
  5. - Inherits from

    Enter the name of the direct superclass.

    Note

    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.

    - 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.

  6. Choose This graphic is explained in the accompanying textSave.
  7. The Create Object Catalog Entry dialog box is displayed.

  8. Enter the Package.
  9. Choose Save again.

Result

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.

See also:

Creating Attributes for Exception Classes

Creating Texts for Exceptions

 

 

Leaving content frame