Attributes of interface parameters in methods

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:

Parameter passing by reference or by value

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.

Typing parameters

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:

t
stands for all data types from the ABAP Dictionary and all ABAP data types known at this point.
ANY
stands explicitly for a parameter declaration without type reference. This means that the parameter inherits all technical attributes of the parameter that has been passed when the method is called.
REF TO cif
stands for a class or interface reference.
LINE OF itab
stands for the line type of an internal table itab.
TYPE [ANY|INDEX|STANDARD|SORTED|HASHED] TABLE
stands for the internal table type of the table type specified.

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.

Optional parameters

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.