ABAP Obsolete - Call Method
Of course, the obsolete command does not mean the use of classes, but rather the use of additional commands to call and use methods.
Table of contents
The use of the addition Call Method is no longer up-to-date and may result in the source code being less readable. In this context, there are also two variants for calling methods:
- Calling Call Method without parentheses is based on the call of function modules and is now very outdated
- Calling with parentheses reminds you of the normal call of methods with the addition of a keyword but also not actual
We would like to show you the current state of development.
Status quo
Currently classes and methods are called as known from other languages. The object is specified, followed by the specification of the method. Within the class, you then have the opportunity to refer to the object or directly call the method that comes from the current class (see examples 1 & 2).
" Call outside a class
lo_obj->do_something( ld_bukrs ).
" Call inside a class (1)
do_something( ld_bukrs ).
" Call inside a class (2)
me->do_something( ld_bukrs ).
Exception
As always, there are exceptions where the call method command is useful and can be used. This is the case if you want to call a local class method in another program.
A small piece of coding for that purpose:
" Special case for calls
CALL METHOD ('PROGRAM={Programm}CLASS={Klasse}')=>('{Methode}')​
EXPORTING
" ...
IMPORTING
" ...
.
In this case, the class is called in another program and the static method is executed. The transfer of parameters is also possible, if you need this.
With this variant, however, the question arises as to whether the method should not already have been outsourced to a global class.
Conclusion
The use of Call Method has long been unnecessary and does not look really modern. It comes from the time of the function modules and should play no role in your modern programming style.
Source:
SAP Documentation CALL METHOD