ABAP - Keyword Documentation →  ABAP - Reference →  Program Layout →  Modularization Statements →  Procedures → 

Parameter Interface of Procedures

The parameter interface of a procedure consists of formal parameters and specifies the exceptions possible in the procedure.

Formal Parameters

Formal parameters are input parameters, output parameters, input/output parameters, or return values. Several obsolete table parameters also exist. Formal parameters are either generic or fully typed. Pass by reference or pass by value can be specified for most formal parameters. Pass by value is mandatory for some formal parameters.

Programming Guideline

Choose the appropriate formal parameter type


Class-based exceptions can be declared using RAISING for all procedures (methods, function modules, and subroutines), and can then be propagated from the procedure. EXCEPTIONS can also be used in methods and function modules to define non-class-based exceptions, which can then be raised in the procedure using RAISE or MESSAGE ... RAISING.

Pass by Reference or Pass by Value

When deciding whether to use pass by reference or pass by value for a formal parameter, the performance and robustness of each pass-by type must be compared.

In ABAP, pass by reference always leads to better performance since no local data object has to be stored and no data transport is necessary when the procedure is called. Therefore, for performance reasons, pass by reference is usually preferable, unless explicit or implicit writes are made to an input parameter in the procedure or if it is necessary to ensure that an input/output parameter or an output parameter is returned only if the procedure ends without any errors. In such cases, pass by value is mandatory, to make sure that the assigned actual parameter is not modified simultaneously in the caller when writes are made to a formal parameter. For performance reasons, only parameters of 100 bytes or less should be passed in these cases, whenever possible.

Also note the following when using pass by reference:

Procedures and their calls have to be programmed so that these kinds of errors do not occur.

To summarize, pass by reference is always preferable when performance is an issue, while pass by value is more suitable in situations where robustness and data consistency are more important. These factors must be taken into account in each individual case when deciding which pass-by type to use with which type of parameter.

Programming Guideline

Choose a suitable pass-by type



For a method meth, CHANGING parameter p1 is defined for pass by reference and p2 for pass by value. The values of both parameters are modified before an exception is raised. The actual parameter a1 bound to the parameter using pass by reference contains the modified value when the exception is handled. The actual parameter a2 bound to the parameter using pass by value, on the other hand, keeps its value.

                   INHERITING FROM cx_static_check.

    CLASS-METHODS meth CHANGING p1        TYPE i
                                VALUE(p2) TYPE i
                       RAISING  cx_exception.

  METHOD meth.
    p1 = 333.
    p2 = 444.
    RAISE EXCEPTION TYPE cx_exception.

  DATA(a1) = 111.
  DATA(a2) = 222.
      cls=>meth( CHANGING p1 = a1
                          p2 = a2 ).
    CATCH cx_exception.
      cl_demo_output=>display( |{ a1 }, { a2 }| ).

Example Pass by Parameter