SAP METHOD CALLS



Get Example source ABAP code based on a different SAP table
  


VERSION 5 IN

Method Calls
There are two types of method call, static method calls and dynamic method calls. In static method calls, the name of the method must be completely known in the program. In dynamic method calls, the name of the method is determined partially or completely at runtime.
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.
Static method calls have the pattern meth( ). They do not need a keyword, but the method is specified directly and the parameters passing is in parentheses instead. Dynamic method calls are introduced using CALL METHOD.
Static method calls
Dynamic method calls
BEGIN_SECTION VERSION 5 OUT
An obsolete syntax variant also exists where static method calls are still introduced using CALL METHOD.
END_SECTION VERSION 5 OUT
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 the assignment of a value, sy-subrc is set to this value.