What does it do? Definition of formal parameters p1 p2 ...> for methods. VALUE> or REFERENCE> determine 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 cannot be changed in the method. The addition typing> must be used to type every formal parameter. 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 in which operand positions the formal parameter can be used in the method.
Latest notes: If a formal parameter is typed as a reference variable and cannot be changed in the procedure>, the type check is performed as for an upcast>. If it can be changed in the procedure, the actual parameter must be compatible with the formal parameter. NON_V5_HINTS ABAP_HINT_END • OPTIONAL METHODS • DEFAULT METHODS
ABAP Addition
What does it do? 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 a type-compliant way, but the addition DEFAULT> passes the value and type of the replacement parameter def1 def2 ...> to the formal parameter. Any data object that is visible here that complies with the rules for checking typing> can be specified as replacement parameters def1 def2 ...>, with the exception of the components of boxed components>. If no actual parameter is specified for a generically typed formal parameter using the addition OPTIONAL> when it is called, the type of the formal parameter is completed according to the rules for generic types>.
Latest notes: If a literal is specified after DEFAULT>, the same special rules apply as to literals as actual parameters>. Afterwards, the compatibility may not then be checked completely. Instead, in method calls where no actual parameter is specified for the formal parameter, a literal is converted to the data type of the formal parameter and an exception can be raised if the value of the literal does not fit in the value range of this data type. NON_V5_HINTS ABAP_HINT_END
ABAP_EXAMPLE_VX5 Declaration of a method with two different specifications of input parameters. The specification of REFERENCE(p2)> has the same meaning as p2>. ABEXA 01683 ABAP_EXAMPLE_END