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

ABAP in Change

473

The programming language ABAP has been changing for years and is being modernized in various concepts. In this article, we'll look at it in detail.



For many years now, ABAP has been changing into a modern programming language, away from the beginnings in the direction of Cobol, towards a modern design of the language and the interfaces.

 

Programming language

At that time it started with ABAP OO, at this point the first developers were already asking themselves why one should actually switch to such modern stuff. It wasn't mandatory yet and reports still worked with form routines, so there was no need to switch, especially when most colleagues didn't understand object orientation yet. In some companies, ABAP OO was even banned because it was feared that the systems could no longer be maintained.

Then SAP introduced unit testing, which was already standard in many programming languages. Source code should suddenly be developed with a coverage of tests, with very few developers relying on unit tests, preferring to carry out manual tests as before or rely on customization and work without actual testing.

 

Modern ABAP

From 7.40 the complete modernization of the language began with completely new commands and objects such as core data services, AMDP classes or business objects with BOPF. A lot has happened in the language since this release, you could suddenly use two or more commands for the same thing, coding became much shorter, you thought about maintainable code (topic: refactoring, unit tests) and finally there was also a new programming model with the ABAP RESTful Programming Model (RAP for short).

 

Learn and forget

Now you should primarily deal with the topic of "learning", you should be familiar with more than just ABAP. The web protocol is added to understand OData Services and Fiori. HTML and Javascript to be able to debug Fiori applications and with Git to exchange source code with others or to work on open source projects.

At the same time, forgetting should also be kept in mind. Do you really still need the old statements that have already been replaced by newer and perhaps more powerful ones? Here, too, you should clear out the old ABAP treasure and rely on the new statements. Furthermore, fewer and fewer techniques such as file or screen processing will be required over the next few years. Therefore, newcomers to the topic should look at such topics at most superficially.

 

Example

Here is a small example of a piece of source code in the old notation and after refactoring as a new variant with Modern ABAP:

DATA:
  lt_r_ccode   TYPE tt_r_ccode,
  ls_ccode     LIKE LINE OF lt_r_ccode,
  lt_companies TYPE tt_company,
  ls_company   LIKE LINE OF lt_companies,
  ld_count     TYPE i,
  ld_hcount    TYPE string,
  ld_text      TYPE string.

ls_ccode-sign = 'I'.
ls_ccode-option = 'EQ'.
ls_ccode-low = '0706'.
APPEND ls_ccode TO lt_r_ccode.

CALL METHOD select_some_data
  EXPORTING
    it_r_company_code = lt_r_ccode
    id_currency       = 'EUR'
  RECEIVING
    rt_result         = lt_companies.

DESCRIBE TABLE lt_companies LINES ld_count.
ld_hcount = ld_count.
CONCATENATE 'Number of lines:' ld_hcount INTO ld_text.
CALL METHOD out->write
  EXPORTING
    data = ld_text.

READ TABLE lt_companies INTO ls_company INDEX 1.
IF sy-subrc = 0.
  CALL METHOD out->write
    EXPORTING
      data = ls_company-butxt.
ENDIF.

 

After the revision, the source code looks correspondingly shorter. The large declaration part has disappeared and many multi-line statements could be reduced to one line:

DATA(lt_companies) = select_some_data(
    it_r_company_code = VALUE #( ( sign = 'I' option = 'EQ' low = '0706' ) )
    id_currency = 'EUR'
).

out->write( |Number of lines: { lines( lt_companies ) }| ).

TRY.
    out->write( lt_companies[ 1 ]-butxt ).
  CATCH cx_sy_itab_line_not_found.
ENDTRY.

 

Conclusion

The last few years have been tough for some developers as there has been a lot to learn. For others, it was the best time, which will continue for a few years to come, as there will always be innovations. The ABAP language is changing and we like it too.


Included topics:
QuickABAPChangeTransformation
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 in Practice - String Processing

Category - ABAP

In this practical example we look at the string processing to determine the CDS names in CamelCase and how you can implement this with ABAP.

10/15/2024

ABAP in Practice - Test Driven Development

Category - ABAP

How does TDD actually work in practice and are there simple examples for learning in ABAP? In this exercise we will look at the practical part.

09/24/2024

ABAP in Practice - Merge data sets

Category - ABAP

How do we merge two different data sets in ABAP, especially with regard to Modern ABAP? A practical task for this topic.

09/17/2024

ABAP in Practice - Modern ABAP

Category - ABAP

In this small task we look at existing classic ABAP source code and try to optimize it according to Modern ABAP.

08/27/2024

ABAP Quick - Performance Data Filtering

Category - ABAP

Which statement do you use in ABAP to filter internal tables and is it performant? Read more in this article.

08/13/2024