Skip to content

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

CALL METHOD

Short Reference

Other versions: 7.31 | 7.40 | 7.54

Syntax Forms


Static Method Call

1. [CALL METHOD] static_meth( parameter_list ).
   CALL METHOD  static_meth  parameter_list.

Short Forms

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

Functional Method Call

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

Method Chaining

4. ... { static_meth( ... )->meth1( ... )->meth2( ... )->...->meth( ... ) }
    | { static_meth( ... )->meth1( ... )->meth2( ... )->...->attr        } ...


Dynamic Method Call

5. CALL METHOD dynamic_meth { parameter_list
                           | parameter_tables }.

Effect

Method call in ABAP Objects. There is a difference between static method calls, where the name of the method must be fully known in the program, and dynamic method calls, where the method ID is determined entirely or in parts at runtime. A static method call can be executed in different forms. In one form, the parameters are passed in a parenthetical expression, in the other without a parenthetical expression. For the parenthetical expression, short forms are allowed. Method chainings are also an option. In dynamic method calls, the parameters cannot be specified in parentheses and the statement CALL METHOD must be used.

When an instance method is called using a reference variable and the static type of the reference variable is a superclass of the dynamic type, the dynamic method call can be used to call all visible methods of the dynamic type. In static method calls, however, only the visible methods of the static type can be called.

System Fields

The system field see-subrc is set to 0 when a method is called. If a non-class-based exception is raised that was handled by the assignment of a value, then see-subrc is set to this value.

Exceptions


Catchable Exceptions

CX_SY_DYN_CALL_EXCP_NOT_FOUND

  • Cause: Exception does not exist
    Runtime Error: DYN_CALL_METH_EXCP_NOT_FOUND

CX_SY_DYN_CALL_ILLEGAL_CLASS

  • Cause: Specified class does not exist
    Runtime Error: DYN_CALL_METH_CLASS_NOT_FOUND

CX_SY_DYN_CALL_ILLEGAL_METHOD

  • Cause: Method cannot be accessed.
    Runtime Error: CALL_METHOD_NOT_ACCESSIBLE
  • Cause: The called method is not implemented.
    Runtime Error: CALL_METHOD_NOT_IMPLEMENTED
  • Cause: Calls the static constructor
    Runtime Error: DYN_CALL_METH_CLASSCONSTRUCTOR
  • Cause: Calls the instance constructor
    Runtime Error: DYN_CALL_METH_CONSTRUCTOR
  • Cause: Method does not exist
    Runtime Error: DYN_CALL_METH_NOT_FOUND
  • Cause: Method is not static
    Runtime Error: DYN_CALL_METH_NO_CLASS_METHOD
  • Cause: Calls a non-visible method
    Runtime Error: DYN_CALL_METH_PRIVATE
  • Cause: Calls a non-visible method
    Runtime Error: DYN_CALL_METH_PROTECTED

CX_SY_DYN_CALL_ILLEGAL_TYPE

  • Cause: Type conflict during method call.
    Runtime Error: CALL_METHOD_CONFLICT_GEN_TYPE
  • Cause: Type conflict during method call.
    Runtime Error: CALL_METHOD_CONFLICT_TAB_TYPE
  • Cause: Type conflict during method call.
    Runtime Error: CALL_METHOD_CONFLICT_TYPE
  • Cause: Incorrect parameter type
    Runtime Error: DYN_CALL_METH_PARAM_KIND
  • Cause: Actual parameter cannot be filled
    Runtime Error: DYN_CALL_METH_PARAM_LITL_MOVE
  • Cause: Incorrect table type for a parameter
    Runtime Error: DYN_CALL_METH_PARAM_TAB_TYPE
  • Cause: Incorrect parameter type
    Runtime Error: DYN_CALL_METH_PARAM_TYPE

CX_SY_DYN_CALL_PARAM_MISSING

  • Cause: Missing actual parameter
    Runtime Error: DYN_CALL_METH_PARAM_MISSING
  • Cause: Parameter reference is empty
    Runtime Error: DYN_CALL_METH_PARREF_INITIAL

CX_SY_DYN_CALL_PARAM_NOT_FOUND

  • Cause: Incorrect parameter name
    Runtime Error: DYN_CALL_METH_PARAM_NOT_FOUND

CX_SY_REF_IS_INITIAL

  • Cause: Reference variable is empty
    Runtime Error: DYN_CALL_METH_REF_IS_INITIAL


Non-Catchable Exceptions

  • Cause: Unallowed parameters for dynamic method call. Relevant for instance constructors during dynamic intantiation.
    Runtime Error: CALL_METHOD_PARMS_ILLEGAL

Continue

CALL METHOD - static

CALL METHOD meth( ... )

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

... meth1( ... )->meth2( ... )->...

CALL METHOD (meth_name)

CALL METHOD - parameter_list

CALL METHOD - parameter_tables