ABAP Keyword Documentation → ABAP - Reference → Declarations → Declaration Statements → Classes and Interfaces → Components in Classes and Interfaces → Methods → METHODS
METHODS - parameters
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
Defines formal parameters p1 p2 ...
for methods.
VALUE
or REFERENCE
are used to define whether a parameter p1 p2 ...
is passed by
value or by
reference. If only
one name p1 p2 ...
is specified, the parameter is passed by reference by default. An input parameter passed by reference must not be changed in the method.
If the addition typing
is used, every formal parameter must be typed. The syntax of typing
is described in
Typing Syntax. The typing of a formal parameter causes the data type to be
checked against the typing when an actual parameter is passed. The typing also defines at which operand positions the formal parameter can be used in the method.
OPTIONAL
or DEFAULT
can be used to define input
parameters and input/output parameters as optional parameters, where DEFAULT
can be used to specify a replacement parameter def1 def2 ...
. No actual parameter
needs to be specified for an optional parameter when the method is called. The addition OPTIONAL
is used to initialize a formal parameter in accordance with type, but the addition DEFAULT
passes the value and type of the replacement parameter def1 def2 ...
to the
formal parameter. The replacement parameter def1 def2 ...
can be specified as any appropriate data object at this position except for components of
boxed components.
If no actual parameter is specified for a generically typed formal parameter with the addition OPTIONAL
when it is called, the type of the formal parameter is completed according to
fixed rules.