Creating Parameters and Exceptions 

You define methods in a similar way to function modules. Firstly, you create interface parameters and exceptions. Then, you code (implement) the method. Methods can have input parameters - the importing and changing parameters, and output parameters - their exporting, changing, and returning parameters.

Prerequisites

When you redefine inherited methods, you may not change the interface parameters (signature) nor add new parameters.

Procedure

Creating Parameters

  1. Position the cursor on the name of the method or event.
  2. Choose Parameters.
  3. To create parameters of methods or events, enter the following information:

    - Parameter
    A unique name for the parameter. Ensure that you observe the
    naming conventions for method parameters in ABAP Objects

    - Type
    As in function modules, a parameter can have the type, importing, exporting, changing, or returning.
    Note the following special rules:
    If you use changing parameters, you cannot use returning parameters. If you use returning parameters, you cannot use exporting or changing parameters.
    Constructor methods may only have importing parameters.


    - Pass Value
    Unlike function modules, the default way of passing values to a method is by reference. However, you can force the system to pass a parameter by value by selecting this option. This is only possible for importing, exporting, and changing parameters. Returning parameters can only be passed by value. The Class Builder automatically checks against this rule.

    - Optional
    If you select this option, the parameter does not have to be specified when the method is called.

    - Typing method
    ABAP keyword defining the type reference. You can use Type, Like, and Type ref to.

    - Reference type
    This may be any elementary ABAP type (including generic types) or object type (class or interface). For further information, refer to the
    Data Types section of the ABAP Programming Guide.
    You can specify the type of a parameter of a private or protected method using an internal data type defined in the class.

    - Default value
    Default value for the parameter

    - Description
    A short description of the parameter.

Creating Exceptions

  1. Position the cursor on the name of the corresponding method.
  2. Choose Exceptions.
  3. To define exceptions for methods, enter the following information:

    - Exception
    A name for the exception. Remember to observe the
    naming conventions for exceptions in ABAP Objects.

    - Description
    A short description of the exception.

Result

You have now created the interface parameters and exceptions for a method. You can now implement the method.