This is a test message to test the length of the message box.
Login
New ABAP internal tables performance
Created by Software-Heroes

ABAP - Internal tables (performance)

690

The second part for the topic internal tables, their processing and performance in accessing the data. Today with a focus on performance in reading the data.

What you should consider when accessing the new methods is, above all, the topic of performance. If you need to read a lot of data and often from internal tables, these should also be prepared for it.

Reading via the index, if possible, is always the best way. But this often doesn't work that way. In the following, we will explain how it relates with the access to the data.

 

Read over the index

Reading via the index is always fast, here SAP has its own key that speeds up access to special lines. Nothing has to be adjusted or improved on the performance, this key is always fast.


" Index access
DATA(ls_t001) = lt_t001[ 1 ].

 

Read with keys

It looks a bit more critical when reading a key. Here it should be noted whether the table has a key and is sorted accordingly.

Performance problems make the standard tables in most cases because they either have a "scrap" or "empty" key. Here is only useful to read, if the amount of data is less than 100 records, because everything else is just unbearably slow.

That's why we have put together a list for you to show you the most common fast and slow reads.

 

Slow access
  • Standard tables with default/empty key
  • Tables with secondary key without accessing this key

 

Fast access
  • Sorted tables
  • Hashed tables
  • Secondary key with accessing this key
  • Read table mit binary search (date have to be sorted)

 

For a better presentation and visualization of accesses, we would like to introduce you in the third part of this article a simple report, with which you can check/test reads and access times.

 

Read fields

If you work with a free key for access and only want to read fields from the table, you should only do so with one field. Quickly you will be tempted to use this access over and over again. But you should remember that each of these requests triggers a re-reading of the internal table, which can lead to performance problems.


" Bad example
ls_data-waers = lt_t001[ bukrs = 'ABCD' ]-waers.
ls_data-btext = lt_t001[ bukrs = 'ABCD' ]-butxt.
ls_data-taxno = lt_t001[ bukrs = 'ABCD' ]-stceg.

" Better example
DATA(ls_t001) = lt_t001[ bukrs = 'ABCD' ].
ls_data-waers = ls_t001-waers.
ls_data-btext = ls_t001-butxt.
ls_data-taxno = ls_t001-stceg.

 

Conclusion

When reading the internal tables, we focused on the topic of New ABAP, in order to highlight the innovations and possible sources of error. When accessing via READ TABLE you can avoid some of the weaknesses of the new features, but then it is also the old familiar programming style.


Included topics:
New ABAPInternal tablePerformance
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 - RETURN value

Category - ABAP

After all these years, the “real” return in ABAP has finally arrived. In this article we will show you how it works and what it can do.

02/13/2024

ABAP Deep Dive - FOR (Loops)

Category - ABAP

Let's take a closer look at the FOR loop. How does it work? What do I have to consider and what can I do with it?

04/14/2023

ABAP Deep Dive - Table access (internal)

Category - ABAP

In this article, let's take a look at table access to internal tables and how they replace READ TABLE.

02/03/2023

ABAP Developer still relevant

Category - ABAP

In this article we look at whether ChatGPT can already replace an ABAP developer or whether it can be used as a help in everyday life.

01/06/2023

ABAP - FINAL

Category - ABAP

In this article, we'll take a look at the new FINAL language construct, how it works, and what you can do with it.

12/23/2022