This is a test message to test the length of the message box.
Login
ABAP Obsolete Call Method
Created by Software-Heroes

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.

Advertising

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


Included topics:
ObsoleteCALL METHOD
Comments (0)
Advertising

ABAP - Naming conventions

Category - ABAP

How important is it nowadays to adhere to naming conventions or even to use naming conventions in the modern ABAP environment? We want to look at that in this article.

04/09/2021

ABAP - Use INSERT

Category - ABAP

APPEND already has a long history in ABAP, but this will play less and less of a role in the future. We'll show you why.

12/11/2020

ABAP Obsolete - Assignment and calculation

Category - ABAP

How does it actually work with the assignments and the calculation in ABAP? Here you will find out the current language constructs and what you should avoid.

06/26/2020

ABAP Obsolete - Ranges and Headers

Category - ABAP

Generate a decent range for an interface? Tables with or without header lines? We show you what is still possible and what you should rather be.

06/12/2020

ABAP Obsolete - DESCRIBE

Category - ABAP

Again we have for you a most used ABAP term for which there is already a new alternative, this time not just one alternative.

11/15/2019