Entering content frame

Procedure documentation Creating Parameters for Methods Locate the document in its SAP Library structure

You define methods in a similar way to function modules. First you create interface parameters and exceptions and then you code (implement) the method. The input parameters include the Importing and Changing parameters. The output parameters can be Exporting , Changing and Returning parameters.

Prerequisites

The method for a class or interface was already created.

Note

When you redefine inherited methods, you may not change the signature.

Procedure

To create a parameter for a method:

  1. Select the class or interface and change to the Class Editor.
  2. Choose Methods.
  3. Position the cursor on the name of the method or event.
  4. Choose Parameters.
  5. To define parameters of methods or events, enter the following information:

    - Parameter
    A unique name for the parameter. Remember to observe the
    naming conventions for the parameters that are local to the method under ABAP Objects.

    - Category
    As for function modules, a parameter can be passed with 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.

    - Value transfer
    In contrast to function modules, parameters for methods are normally passed 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 for defining the type reference. You can use Type, Like, and Type ref to.

    - Reference type
    You can use any elementary ABAP type (including generic types) or object type (classes and interfaces). For more information see
    Structure link Data Types in the ABAP manual.
    Parameters can also be defined with data types for the specific classes when using private and protected methods.

    - Default value
    Default value for the parameter.

    - Description
    Short description of the parameter.

    This graphic is explained in the accompanying text

Result

You defined interface parameters for a method and can now implement the method.

See also:

Implementing Methods.

 

 

Leaving content frame