Ansicht
Dokumentation

ABAPCALL_METHOD_DYNAMIC - CALL METHOD DYNAMIC

ABAPCALL_METHOD_DYNAMIC - CALL METHOD DYNAMIC

ABAP Short Reference   BAL Application Log Documentation  
This documentation is copyright by SAP AG.
SAP E-Book

CALL METHOD

Short Reference



CALL METHOD dynamic_meth ${ parameter_list
                         $| parameter_tables $}.

Effect

This statement calls the method specified dynamically in dynamic_meth (Dynamic Invoke). Actual parameters are assigned to the formal parameters of the method, either statically using parameter_list or dynamically using parameter_tables. The syntax of parameter_list is the same as for explicit parameter specification for the static method call.

System Fields

Each method call sets the system field sy-subrc to 0 in the moment the method is called. Handling non-class-based exceptions can change this value.

Notes

  • In the dynamic method call, the parameters are not passed in parentheses. The syntax of the dynamic method call is like that of a function module call.

System Fields

The system field sy-subrc is set to 0 when a method is called. If a non-class-based exception is raised and is handled by then assigning a value, sy-subrc is set to this value.

Example

Dynamic call of the static method GUI_DOWNLOAD of the global class CL_GUI_FRONTEND_SERVICES for storing the content of an internal table in a file on the current presentation server. The names of the class and method are specified in the strings class and meth. The interface parameters are passed using the internal table ptab and return values are assigned to the exceptions of the method using the table etab. Exceptions that are raised at the method call itself are handled in a TRY control structure with statement CATCH.

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   CPI1466 during Backup  
This documentation is copyright by SAP AG.

Length: 9251 Date: 20240329 Time: 110149     sap01-206 ( 91 ms )