Skip to content

ABAP Keyword Documentation →  ABAP - Reference →  Declarative statemnts →  Classes and Interfaces →  Components in Classes and Interfaces →  Methods →  METHODS 

METHODS - parameters

Short Reference

Other versions: 7.31 | 7.40 | 7.54

Syntax


... { VALUE(p1) | REFERENCE(p1) | p1 } 
        typing
[OPTIONAL|{DEFAULT def1}]
    { VALUE(p2) | REFERENCE(p2) | p2 }
        typing
[OPTIONAL|{DEFAULT def2}]
    ... .

Effect

Definition of formal parameters p1 p2 ... for methods.

Use VALUE or REFERENCE to determine whether a parameter p1 p2 ... is passed by value or by reference. If only one name p1 p2 ... is specified, the parameter is by default passed by reference. An input parameter passed by reference must not be changed in the method.

With addition typing, every formal parameter must be typed. The syntax of typing is described in Typing Syntax. The typing of a formal parameter has the effect that when an actual parameter is passed, its data type is checked against the typing. In addition, the typing determines at which operand positions the formal parameter can be used in the method.

Use OPTIONAL or DEFAULT to define input parameters and input/output parameters as optional parameters, where you can use DEFAULT to specify a replacement parameter def1 def2 .... For an optional parameter, you need not specify an actual parameter in the method call. While a formal parameter with the addition OPTIONAL is initialized according to its type, a formal parameter with addition DEFAULT copies the value and type of the replacement parameter def1 def2 .... As a replacement parameter def1 def2 ..., you can specify any appropriate data object that is visible at this position except for components of Boxed Components.

If no actual parameter is specified for a generically typed formal parameter with the OPTIONAL addition at the time of the call, the type of the formal parameter is completed according to fixed rules.


Note

If a formal parameter is typed as a reference variable and cannot be changed in the procedure, then the typing is executed as for an Up Cast. If it can be changed in the procedure, then the actual parameter must be compatible to the formal parameter.