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

Modernize your ABAP

466

What is behind this somewhat provocative statement and how can you gradually get to modern ABAP? Everything in this article.

ABAP is a language that has grown strongly historically and, in contrast to other programming languages, no old language constructs have been removed from the vocabulary so that ABAP is always backwards compatible. But should you still program like you did 20 or 30 years ago?

 

Introduction

There are over 1250 keywords in ABAP, making the programming language TOP 1 among the languages. But the amount of keywords is rather counterproductive, as they prevent beginners from learning the language quickly. Let's look at the usage of REFRESH, CLEAR and FREE. Here are three statements that do roughly the same thing, but which one should you choose and which one still makes sense today? Old ABAP hands will probably argue about it, but actually you should only use one statement and you've saved yourself two others.

 

Beginning

Where to start reducing language? In our opinion, especially in the training of new ABAP developers. This is where the foundation for development is laid and young ABAP developers should primarily learn how the new things work. It is of little use to them if they start with FORMS and function blocks. Getting information about old statements later through the technical documentation is not a problem, but it is important to familiarize them with the new statements.

Most importantly, current developers should start looking at and using the new statements. In most cases, these are even better performance-optimized and can be combined more easily in statements.

 

Obsolete

A very good hint for keywords that are no longer to be used can be found in the ABAP documentation. If you are not sure about a command, then look at the technical documentation, there you will find information about obsolete statements first and foremost:

 

You can delete such statements directly from your vocabulary of the programming language.

 

Replacement

It becomes a little more difficult when determining successors to keywords or best practices when developing. The Clean ABAP Guide provides important information or simply visit our website, where we have compiled a list of Modern ABAP Statements. You will also find new and old, as well as numerous blogs on the subject of Modern ABAP and how to use the new syntax.

 

ABAP Cloud

SAP has started to clean up the language a bit when it comes to the latest codelines and releases. If we take a closer look at the ABAP Environment, we will soon see that not everything is possible. Here the language has already been severely restricted and not everything is possible anymore. Even if the system still works in the background, the language version is restricted by the compiler. As a result, ABAP is automatically restricted in terms of language scope and developers can only use many of the new statements.

SAP is taking a hard but correct path here. Form-based reports and applications are a thing of the past and there is no other way to switch to the web and Fiori. But how to quickly and easily create Fiori applications with Fiori Elements fits better into another article on our blog.

 

Examples

Let's look at a few examples and how we can make language a little easier for everyone.

 

APPEND vs. INSERT

We have already compared the two statements in an article. APPEND is no longer required and can also be forgotten. INSERT always works as expected and does not cause problems when changing the data type. This saves you time eliminating errors and changing the statements.

" Old
APPEND ls_structure TO lt_table.

" New
INSERT ls_structure INTO TABLE lt_table.

 

Comparison operators

Who doesn't know it from learning ABAP, what does LE or GT do? These expressions for relational operators are required in the SELECT-OPTIONS environment, but they can also be used to carry out comparisons in IF statements. However, readability will suffer here, since these operators first have to be interpreted. They can no longer be used when modeling CDS views, which in turn causes a break in development and leads to unsightly mixing.

" Old
IF ld_number GE 10.
ENDIF.

" New
IF ld_number >= 10.
ENDIF.

 

Younger developers usually also look at other programming languages or develop as full-stack developers in the Fiori area. Since the old comparison operators don't work here, sooner or later there will be a break. It pays to get into the habit of using the standard comparison operators right away.

 

Initialize

At the beginning we addressed the three statements REFRESH, CLEAR and FREE. Refresh is already obsolete and should no longer be used. Clearly CLEAR should be used here, since intuitively it can also be used much better to clean up variables. FREE was mainly used to clean up tables and objects, but the difference to CLEAR is only minimal and can be neglected.

" Old
REFRESH: lt_table, ld_variable.

" New
CLEAR: lt_table, ld_variable.

 

Conclusion

Modern ABAP is not difficult, it requires a little help and getting used to, but this way you can step by step to a better style. Our recommendation to you, if you are unsure, always use the latest expression when developing.


Included topics:
SAPABAPModern ABAP
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 Development Days 2024

Category - ABAP

DSAG's ABAP Development Days 2024 have come to an end. This article takes a brief look back at the most exciting topics and insights from the two days.

05/10/2024

DSAG Technology Days 2024 & TechXchange

Category - ABAP

The Technology Days in Hamburg are over, let's take a look back and look at the new TechXchange format in detail.

02/09/2024

Autumn 2023 - ABAP and SAP events

Category - ABAP

What more ABAP and SAP events are there before 2023 comes to an end? In this short summary you will get all the information.

10/30/2023

Devtoberfest 2023 Recap

Category - ABAP

Devtoberfest is coming to an end, here is a brief review of the topics and information in the area of ABAP and low-code.

10/13/2023

DSAG Annual Congress 2023

Category - ABAP

This year's DSAG Annual Congress is over, we have heard a lot and we want to share our impressions with you.

09/22/2023