Entering content frameProcedure documentation Creating Exceptions for Methods Locate the document in its SAP Library structure

Use

When you create an exception for a method, you can decide if you want to use the classical exceptions or the new class-based exceptions in the method. When you use the class-based method, exceptions are represented with objects of exception classes at runtime.

Prerequisites

The method for a class or interface was already created.

Procedure

To create an exception for a method:

  1. Place the cursor on the name of the corresponding method in the method display of the Class Editor.
  2. Choose Exceptions.
  3. If you want to define normal exceptions for the method, enter the following:

    - Exception
    Specify a suitable name for the exception. You must adhere to the
    naming conventions for exceptions under ABAP objects.

    - Description
    Short description of the exception.

    If you want to create a class-based exception, first activate the Exception classes checkbox and then enter the appropriate exception class(es) under Exception. Once you have pressed
    ENTER , the Class Builder checks if the specified exception classes really exist. If a class does not exist, you can create it at this time. Otherwise the class description is copied.

Example:
This graphic is explained in the accompanying text

Result

You defined exceptions for a method and can now implement the method.

See also:

Defining Exception Classes

Implementing Methods.

 

 

Leaving content frame