Skip to content

ABAP Keyword Documentation →  ABAP − Reference →  Obsolete Language Elements →  Obsolete Calls 

CALL METHOD - Static Method Call (Obsolete)

Quick Reference

Other versions: 7.31 | 7.40 | 7.54

Obsolete Syntax

CALL METHOD { meth( )
            | meth( a )
            | meth( p1 = a1 p2 = a2 ... )
            | meth( [parameter_list] ) }.

CALL METHOD   meth  [parameter_list].

Effect

Both statements have the same semantics and call the method that is specified statically by the name meth.

  • The first statement prefixes the standalone method call with a CALL METHOD.
  • The second statement does not have any parentheses for passing values to the parameter interface. Instead, either an explicit parameter list is specified or no parameter list at all

In the second variant without parentheses, no chained method calls are possible and the operators NEW and CAST cannot be used to specify the method.


Notes

  • It is not necessary to prefix the recommended syntax with CALL METHOD since this would make programs harder to read.

  • The syntax without parentheses is based on function module calls and is obsolete. The syntax involving parentheses, however, standardizes both standalone and functional method calls.
The statement CALL METHOD is now only intended for dynamic method calls and distinguishes them clearly from static calls.
  • The static method call described here is not to be confused with the call of static methods. A static method call is the static specification of an instance method or a static method. In addition, there is the dynamic method call, for which the methods are specified dynamically.


Example

The three method calls in the following source code have the same meaning. The first two calls are the obsolete variants with CALL METHOD: one without parentheses and one with. The third call is the recommended variant, without CALL METHOD.

CLASS cls DEFINITION. 
  PUBLIC SECTION. 
    METHODS do_something IMPORTING p1 TYPE i 
                                  p2 TYPE i 
                         EXPORTING p3 TYPE i 
                                  p4 TYPE i 
                         RETURNING VALUE(r) TYPE i. 
ENDCLASS. 

CLASS cls IMPLEMENTATION. 
  METHOD do_something. 
    ... 
  ENDMETHOD. 
ENDCLASS. 

START-OF-SELECTION. 

  DATA(oref) = NEW cls( ). 

  CALL METHOD 
    oref->do_something 
    EXPORTING 
      p1 = 333 
      p2 = 444 
    IMPORTING 
      p3 = DATA(a1) 
      p4 = DATA(a2) 
    RECEIVING 
      r  = DATA(a3). 

  CALL METHOD 
    oref->do_something( 
    EXPORTING 
      p1 = 333 
      p2 = 444 
    IMPORTING 
      p3 = DATA(b1) 
      p4 = DATA(b2) 
    RECEIVING 
      r  = DATA(b3) ). 

  oref->do_something( 
    EXPORTING 
      p1 = 333 
      p2 = 444 
    IMPORTING 
      p3 = DATA(c1) 
      p4 = DATA(c2) 
    RECEIVING 
      r  = DATA(c3) ).