Skip to content

ABAP Keyword Documentation →  ABAP - Reference →  Calling and leaving program units →  Calling Processing Blocks →  Calling procedures →  CALL METHOD 

... meth( ... ) ...

Other versions: 7.31 | 7.40 | 7.54

Syntax


... { static_meth( ) 
      | static_meth( a )
      | static_meth( p1 = a1 p2 = a2 ... ) } ...

Effect

Functional call of a functional method static_meth in a suitable reader position for functions and expressions. The return value of the method declared using RETURNING is used as an operand and its full typing determines the data type of the operand. The semantics of the syntax used to pass parameters is identical to that of the short form of CALL METHOD.

If the functional method has the same name as a predefined function, the functional method is always called.


Notes

  • In functional method calls, class-based exceptions 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 cannot be handled, however, and always produce a runtime error.
  • The same applies to resumable exceptions in functional method calls as in all other methods. If processing can be resumed successfully, execution of the statement called in the method can be completed.
  • Method chaining is possible in the operand positions where functional methods can be specified.


Example

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

CLASS math DEFINITION. 
  PUBLIC SECTION. 
    METHODS factorial 
       IMPORTING n TYPE i 
       RETURNING value(fact) TYPE i. 
ENDCLASS. 

CLASS math IMPLEMENTATION. 
  METHOD factorial. 
    fact = 1. 
    IF n = 0. 
      RETURN. 
    ELSE. 
      DO n TIMES. 
        fact = fact * sy-index. 
      ENDDO. 
    ENDIF. 
  ENDMETHOD. 
ENDCLASS. 

DATA oref TYPE REF TO math. 
DATA result TYPE i. 

START-OF-SELECTION. 

  CREATE OBJECT oref. 
  result = oref->factorial( 4 ).