Interface parameters in methods are input parameters (IMPORTING,
CHANGING parameters) and output parameters (EXPORTING,
CHANGING, RETURNING
parameters). In declarations with the statements
METHODS
CLASS-METHODS
EVENTS
CLASS-EVENTS
the following attributes are determined:
With the exception of return codes (RETURNING parameters),
parameters can be passed both by value or reference. In contrast to function modules, passing by reference
is standard with methods. If only a name p is specified
in the parameter declaration, the parameter is passed implicitly as a reference. If a
VALUE(p) is specified instead, then the parameter
is passed as a value. Return codes may only be passed as values. Passing by reference can also be explicitly
specified with other parameters using REFERENCE(p).
An IMPORTING parameter transferred by reference, cannot be changed in the method.
All parameters
must be typed during declaration using the addition TYPE
or the addition LIKE. The following entries are allowed after TYPE as parameter types:
With LIKE you can only
refer to data types of class attributes known at this point in ABAP
Objects and not to data types from the ABAP Dictionary.
Parameters are thus either
fully typed (for example
TYPE I or LIKE),
partially typed (for example TYPE C), or not typed at
all (
TYPE ANY). Return codes (RETURNING
parameter) must always be fully typed. The type check during the method call is made as with subroutines or function modules.
All input parameters ( IMPORTING, CHANGING parameters) can be defined in the declaration as optional parameters using the additions OPTIONAL or DEFAULT. These parameters must not necessarily be transfered when the method is called. With the addition OPTIONAL your parameter remains initialized according to type, while the addition DEFAULT allows you to enter a start value.