Documentation View

We are hiring and constantly growing! Have a look through our vacancies to find the right role for you!

ABAPMETHODS_PARAMETERS - METHODS PARAMETERS

ABAPMETHODS_PARAMETERS - METHODS PARAMETERS

Fill RESBD Structure from EBP Component Structure   SUBST_MERGE_LIST - merge external lists to one complete list with #if... logic for R3up  
This documentation is copyright by SAP AG.
SAP E-Book

METHODS, parameters

Short Reference



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

Addition:

... OPTIONAL$|${DEFAULT def$}

Effect

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.

Note

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.

Addition

... OPTIONAL$|${DEFAULT def$}

Effect

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.

Note

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.

Example

Declaration of a method with two different specifications of input parameters. The specification of REFERENCE(p2) has the same meaning as p2.

CLASS cls DEFINITION.
  PUBLIC SECTION.
    METHODS
      meth
        IMPORTING
          p1            TYPE i
          REFERENCE(p2) TYPE i DEFAULT 111
          VALUE(p3)     TYPE i OPTIONAL.
    ...
ENDCLASS.






ROGBILLS - Synchronize billing plans   Vendor Master (General Section)  
This documentation is copyright by SAP AG.

Length: 5260 Date: 20230207 Time: 085210     sap01-206 ( 76 ms )