Ansicht
Dokumentation

ABAPCALL_METHOD_FUNCTIONAL - CALL METHOD FUNCTIONAL

ABAPCALL_METHOD_FUNCTIONAL - CALL METHOD FUNCTIONAL

CPI1466 during Backup   PERFORM Short Reference  
This documentation is copyright by SAP AG.
SAP E-Book

meth( ... ), Functional Method Call

... ${ meth( )
   $| meth( a )
    $| meth( p1 = a1 p2 = a2 ... )
    $| meth( $[ EXPORTING p1 = a1 p2 = a2 ...$]
            $[IMPORTING p1 =a1 p2 = a2 ...$]
            $[CHANGING  p1 =a1 p2 = a2 ...$] ) $} ...

Effect

Functional call of a functional method meth in a suitable read position for functions and expressions. The return value of the method declared using RETURNING is used as an operand and its complete typing determines the data type of the operand. The actual parameters bound to output parameters and input/output parameters are handled in the same way as in standalone method calls.

The semantics of the syntax used in parameter passing are the same as in standalone method calls. Functional method calls differ from standalone method calls in the following ways:

  • The return value in functional method calls cannot be assigned to an actual parameter explicitly using RECEIVING.
  • Non-class-based exceptions cannot be handled using EXCEPTIONS.

If the return value of the method has a structured data type, a functional method call can, like a structure, be listed in front of the structure component selector - and used to access a component of the structure.

If a functional method has the same name as a built-in function, the functional method is always called.

If an exception is raised when the functional method call is used as an operand, it cannot always be handled, but can cause a runtime error, depending on the position of the operand.

System Fields

Each method call sets the system field sy-subrc to 0 in the moment the method is called.

Notes

  • In functional method calls, class-based exceptions that are propagated from the method can be handled as usual in a TRY control structure or propagated further. The non-class-based exceptions of a functional method, however, always produce a runtime error.
  • The same applies to resumable exceptions in functional method calls as to all other methods. If processing can be resumed successfully, the execution of the statement called in the method is completed.
  • Method chaining is possible in the operand positions where functional methods can be specified.
  • A functional method call whose first method is an instance method can be introduced using the instance operator NEW or the casting operator CAST.
  • In functional calls of a functional method, an implicit temporary actual parameter is always assigned to the return value and this parameter is used as the operand of the current operand position. This means that the predicate expression IS SUPPLIED is always true for the return value within a functionally called method.
  • Since functional method calls can be nested in any way, inline declarations for actual parameters could lead to confusing effects and are therefore not allowed.
  • Since each successful method call sets the system field sy-subrc to 0, all statements with functional method calls can change the value of this field.
  • When used as operands of arithmetic expressions, the results of functional calls of a functional methods are calculated before evaluating the arithmetic expression and their result is buffered for usage in the respective operand position. This might lead to unexpected results, especially if the method call has side-effects. See the example under Arithmetic Expressions.

Example

Functional call of a method. Unlike in the example for standalone method calls, the return value is assigned to the result. The inline declarations made here, however, are not possible.

Example

The functional method factorial in this example has the return value fact of type int8, used on the right side of an assignment in an expression.

Example

The functional method get in this example has a structured return value whose component carrname is accessed.






BAL_S_LOG - Application Log: Log header data   Vendor Master (General Section)  
This documentation is copyright by SAP AG.

Length: 7763 Date: 20240328 Time: 100436     sap01-206 ( 101 ms )