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)

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)

ABAP Deep Dive - VALUE

Category - ABAP

In this article we want to look at the value statement again in all its forms and how you can use it in your daily work.

11/11/2022

ABAP - Common Table Expression (CTE)

Category - ABAP

In this article we want to take a look at the general table expression WITH and how you can use it in everyday life.

10/28/2022

ABAP Deep Dive - CORRESPONDING

Category - ABAP

In this article, a little more about the new Corresponding Statement and how to use it in detail. Let's take a look at the additional features.

09/16/2022

ABAP - Step

Category - ABAP

Today a new addition for the loops and how you can use it. With Step you have the possibility to skip steps in a loop.

09/02/2022

ABAP - Text, String, Template

Category - ABAP

How do I use character strings in modern ABAP development and how do they behave together with inline declarations. We also look at errors that can happen with it.

01/14/2022