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.

Advertising

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)
Advertising

ABAP - Predicative Method Call

Category - ABAP

Due to the OO concept, own methods are usually used for complex queries. This article is about comparing the result from such methods.

05/14/2021

ABAP - Performance for the SELECT

Category - ABAP

In this article we will look at a few special cases with the SELECT and examine the performance of these constructs. We'll show you the current alternatives and give you little tips while reading.

04/02/2021

ABAP - Check objects (Instances)

Category - ABAP

In this article we will show you how you can analyze instances and react to them correctly, for example if you hand them over during processing and want to react individually.

03/19/2021

ABAP - Loops

Category - ABAP

With New ABAP, new loops and possibilities for restricting table contents were created. We'll take a closer look at these new commands in this article.

02/19/2021

ABAP - Comparison

Category - ABAP

Today we'll look at comparisons and comparison operators in terms of the new commands and their current usage. What has changed so far and what should still be done?

02/12/2021