SAP CALL METHOD DYNAMIC ABAP Statements
Get Example source ABAP code based on a different SAP table
Standard SAP Help for CALL_METHOD
CALL METHOD
• CALL METHOD ABAP Statement
ABAP Syntax
What does it do? This statement calls the method dynamically specified in
Latest 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
ABAP Code Snippet
Security Note
ABAP Code Snippet If used wrongly, dynamic calls of program units can present a serious security risk. Names of program units that are passed to a program from the outside must be checked thoroughly before being used in dynamic calls. The system class
ABAP Code Snippet
ABAP Code Snippet See
Example ABAP Coding
Dynamic call of the static method
text_tab LIKE STANDARD TABLE OF line,
filename TYPE string,
filetype TYPE c LENGTH 10,
fleng TYPE i.
DATA: meth TYPE string,
class TYPE string,
ptab TYPE abap_parmbind_tab,
etab TYPE abap_excpbind_tab.
DATA: exc_ref TYPE REF TO cx_sy_dyn_call_error.
class = 'CL_GUI_FRONTEND_SERVICES'.
meth = 'GUI_DOWNLOAD'.
filename = 'c: emp ext.txt'.
filetype = 'ASC'.
ptab = VALUE #( ( name = 'FILENAME'
kind = cl_abap_objectdescr=>exporting
value = REF #( filename ) )
( name = 'FILETYPE'
kind = cl_abap_objectdescr=>exporting
value = REF #( filetype ) )
( name = 'DATA_TAB'
kind = cl_abap_objectdescr=>changing
value = REF #( text_tab ) )
( name = 'FILELENGTH'
kind = cl_abap_objectdescr=>importing
value = REF #( fleng ) ) ).
etab = VALUE #( ( name = 'OTHERS' value = 4 ) ).
TRY.
CALL METHOD (class)=>(meth)
PARAMETER-TABLE
ptab
EXCEPTION-TABLE
etab.
CASE sy-subrc.
WHEN 1.
...
...
ENDCASE.
CATCH cx_sy_dyn_call_error INTO exc_ref.
MESSAGE exc_ref->get_text( ) TYPE 'I'.
ENDTRY.
ABAP Code Snippet
Runtime Exceptions
Catchable Exceptions
Reason for error:
Exception does not exist Runtime error:
Reason for error:
Angegebene Klasse ist abstrakt Runtime error:
Reason for error:
Specified class does not exist Runtime error:
Reason for error:
Method cannot be accessed. Runtime error:
Reason for error:
The called method is not implemented. Runtime error:
Reason for error:
Calls the static constructor Runtime error:
Reason for error:
Calls the instance constructor Runtime error:
Reason for error:
Method does not exist Runtime error:
Reason for error:
Method is not static Runtime error:
Reason for error:
Calls a non-visible method Runtime error:
Reason for error:
Calls a non-visible method Runtime error:
Reason for error:
Type conflict during method call. Runtime error:
Reason for error:
Type conflict during method call. Runtime error:
Reason for error:
Type conflict during method call. Runtime error:
Reason for error:
Incorrect parameter type Runtime error:
Reason for error:
Actual parameter cannot be filled Runtime error:
Reason for error:
Incorrect table type for a parameter Runtime error:
Reason for error:
Incorrect parameter type Runtime error:
Reason for error:
Missing actual parameter Runtime error:
Reason for error:
Parameter reference is empty Runtime error:
Reason for error:
Incorrect parameter name Runtime error:
Reason for error:
Reference variable is empty Runtime error:
Non-catchable Exceptions
Reason for error:
Invalid parameters for dynamic method call. Relevant for instance constructors when instantiated dynamically. Runtime error:
ABAP Code Snippet
Return to menu