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)

996

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 - XCO Strings

Category - ABAP

In this article we look at the XCO class for generating and processing strings for ABAP Cloud and compare it with the classic statements.

11/22/2024

ABAP - XCO Libraries

Category - ABAP

What can you do with the library in ABAP and ABAP Cloud and how do you use the objects the best way? Find out more here.

11/12/2024

ABAP - Type Casting

Category - ABAP

How do you actually get the original type of a class or instance if it is passed in a generic table? In this article we examine the possibilities.

04/16/2024

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