This is a test message to test the length of the message box.
Login
ABAP obsolete refresh
Created by Software-Heroes

ABAP Obsolete - Form

517

When you are buidling a report in SAP the first thing you will need is a usefull structure, this is why many devolpers use Form for this. But what can you do now to replace this obsolete term.



The solution of the problem is quite simple and is already described in the official documentary in a short sentence. In any case, you should only use methods.

Many of the old programs in the system work just like that! They use forms to encapsulate coding components, to bring order into the source code and to reuse program components.

 

Solution

Just use classes! They structure the source code just as well and offer many advantages in handling and implementation in existing coding.

Since the restructuring of the Modern ABAP, many things are much easier. An example would be the implementation of method calls with returning parameters in IF statements, which is not possible with Forms until today.


" Method call
IF lcl_app=>check_selection( ) = abap_false.
  " ... Code or message
ENDIF.

We check the return value of the selection screen and decide how to proceed in the report. This looks simple and clean, but before the modern ABAP that looked a bit different.


" Variable definition
DATA ld_check TYPE abap_bool.

" old version of a call
CALL METHOD lcl_app=>check_selection
  IMPORTING
    ed_check = ld_check.

" Check
IF ld_check = abap_false.
  " ... Code or message
ENDIF.

Here the implementation looks more like the form implementation. That's the reason why many developers prefer to use there old technique, what we can understand at this point too.

 

Usage

The use in a new report is quite simple, you just have to define the class and then implement it, you can already call and use it in any part of the program.


" Class definition
CLASS lcl_app DEFINITION.
  PUBLIC SECTION.
    CLASS-METHODS:
      check_selection
        RETURNING VALUE(rd_check) TYPE abap_bool.

  PRIVATE SECTION.
ENDCLASS.

" Class implementation
CLASS lcl_app DEFINITION.
  METHOD check_selection.
    " ... Code
  ENDMETHOD.
ENDCLASS.

The implementation and definition of the interface are always separate, keeping the code clean. Double-clicking on the method name will allow you to jump between definition and implementation.

 

Advantages

With the implementation and the use of classes, there are also some smaller advantages that we want to mention here.

  • Avoidance of an obsolete command
  • Structure and encapsulation of the report
  • Easy implementation of ABAP unit tests for the automated test of the code
  • Use as inline methods

 

Conclusion

The transition is within your grasp, try it once in a new report or a small evaluation. You will notice how fast you have forgotten the Forms and also an obsolete part of a more modern language.

In a next article, we want to talk a bit more about the structure of a report after the form statement and show you some quick benefits of the structuring.

 

Source:
SAP Documentation - FORM


Included topics:
ObsoleteForm
Comments (0)



And further ...

Are you satisfied with the content of the article? We post new content in the ABAP area every Friday and irregularly in all other areas. Take a look at our tools and apps, we provide them free of charge.


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