Ansicht
Dokumentation

ABAPCALL_METHOD - CALL METHOD

ABAPCALL_METHOD - CALL METHOD

Vendor Master (General Section)   ABAP Short Reference  
This documentation is copyright by SAP AG.
SAP E-Book

CALL METHOD

Short Reference



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 ... ) }.

Chained Method Call

3. {oref->}|{class=>}meth1(...)->meth2(...)->...->meth( parameter_list ).

Dynamic Method Call

4. CALL METHOD dynamic_meth { parameter_list
                           | parameter_tables }.

Effect

Method call in ABAP Objects. There is a difference between a static method call, in which the method ID must be fully known in the program, and a dynamic method call, in which the method ID is determined entirely or in parts at runtime. The 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. You also have the option of chaining methods. In dynamic method calls, you are not allowed to specify the parameters in parentheses and you must use the statement CALL METHOD.

When you call an instance method using a reference variable and the static type of the reference variable is a superclass of the dynamic type, then you can use the dynamic method call to call all visible methods of the dynamic type, whereas with the static method call, you can call only the visible methods of the static type.

System Fields

The system field sy-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 sy-subrc is set to this value.

Note

Functional methods can not only be called with CALL METHOD, but also at operand positions for functions and expressions.

Exceptions

Catchable Exceptions

CX_SY_DYN_CALL_EXCP_NOT_FOUND

  • Cause: Exception does not exist
    Runtime Error: DYN_CALL_METH_EXCP_NOT_FOUND (catchable)

CX_SY_DYN_CALL_ILLEGAL_CLASS

  • Cause: Specified class does not exist
    Runtime Error: DYN_CALL_METH_CLASS_NOT_FOUND (catchable)

CX_SY_DYN_CALL_ILLEGAL_METHOD

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

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: Wrong parameter kind
    Runtime Error: DYN_CALL_METH_PARAM_KIND (catchable)
  • Cause: Actual parameter cannot be filled
    Runtime Error: DYN_CALL_METH_PARAM_LITL_MOVE (catchable)
  • Cause: Wrong table type of a parameter
    Runtime Error: DYN_CALL_METH_PARAM_TAB_TYPE (catchable)
  • Cause: Wrong parameter type
    Runtime Error: DYN_CALL_METH_PARAM_TYPE (catchable)

CX_SY_DYN_CALL_PARAM_MISSING

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

CX_SY_DYN_CALL_PARAM_NOT_FOUND

  • Cause: Wrong parameter name
    Runtime Error: DYN_CALL_METH_PARAM_NOT_FOUND (catchable)

CX_SY_REF_IS_INITIAL

  • Cause: Reference variable is empty
    Runtime Error: DYN_CALL_METH_REF_IS_INITIAL (catchable)


Non-Catchable Exceptions

  • Cause: Illegal parameter at dynamic method call. Relevant for instance constructors at dynamic instantiation.
    Runtime Error: CALL_METHOD_PARMS_ILLEGAL







ABAP Short Reference   General Material Data  
This documentation is copyright by SAP AG.

Length: 9702 Date: 20240616 Time: 121743     sap01-206 ( 92 ms )