SAP CALL METHOD FUNCTIONAL ABAP Statements



Get Example source ABAP code based on a different SAP table
  



meth( ... ), Functional Method Call

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

What does it do?
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.
Inline declarations are not possible for actual parameters.
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.



Latest 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.
A single functional method call can be used as a predicative method call and as a relational expression.
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.
NON_V5_HINTS
ABAP_HINT_END

ABAP_EXAMPLE_VX5
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.
ABEXA 00060
ABAP_EXAMPLE_END

ABAP_EXAMPLE_VX5
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.
ABEXA 00061
ABAP_EXAMPLE_END

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

Return to menu