ABAP in Change
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.
Table of contents
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.