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

ABAP Obsolete - Refresh

1376

The refresh function has been obsolete for quite some time, which function is actually helpfull? Refresh, Clear or Free, what do you need when?



The Refresh function has been obsolete for a while now and is no longer needed because CLEAR and FREE are already available, which can do the same as REFRESH.

 

Using CLEAR

"But Refresh deletes the table body with a header line," you might think. That's right, but you do not need the refresh, because the Clear can do the same, if you pay attention to what you want to delete. As an example, how it was done so far:


" Clear a Select-Option
REFRESH: s_bukrs.
CLEAR: s_bukrs.

Now you can map both lines within one line and the Clear statement:


" Clear a Select-Option
CLEAR: s_bukrs, s_bukrs[].

For the specification of the table body, the square brackets [] are used, which refer to the table. If you omit this, you will refer to the header. Normal tables without header lines require no special handling for this processing and can still use them as before.

Hint: In addition, you should note that the use of tables with header lines is much longer obsolete and this is already prohibited in classes. Select-options and old reports are the only exception to using tables with header lines, which you should edit with structures instead of using the header line.

 

Using FREE

What does the function FREE do? This works on tables as well as refresh, except that it frees the previously set memory by the internal table and the data. With a Clear, only the table lines are deleted, memory occupied by the table is not released.

This may be of great interest if you continue working with the same table in the program and need to keep much data. If you also keep many large tables in the report, you could run out of memory.

 

Clear vs Free

A small report with an example of how the commands work. The report creates two internal tables that are based on table T001 (company code basic data). This should be an example of a bigger structure.


REPORT ztest_clear_vs_free.

DATA:
  lt_tclr TYPE STANDARD TABLE OF t001,
  lt_tfre TYPE STANDARD TABLE OF t001.

" Fill tables
DO 100000 TIMES.
  APPEND VALUE #( butxt = sy-index ) TO lt_tclr.
  APPEND VALUE #( butxt = sy-index ) TO lt_tfre.
ENDDO.

" Clear tables
CLEAR lt_tclr.
FREE lt_tfre.

At the beginning both tables are empty ...

... after the first loop they contain the first lines and allocate memory ...

... at the end the table is completely filled ...

... but the real difference becomes obvious after deleting the table content ...

The entire reserved memory of the table was released with Free, the table has the status before filling. Clear has also cleared the rows, but the memory reserved by the rows is still blocked as long as the variable exists.

The memory allocation can be found in the debugger under the variable display under a separate tab.

 

Conclusion

These are so far but only theoretical constructs and applicable only for a few productive reports. Experience shows that the use of Clear is completely sufficient and you no longer need other statements for daily use. Our recommendation is therefore clear to use CLEAR.

 

Source:
Documentation Refresh
Documentation Clear
Documentation Free


Included topics:
ObsoleteRefresh
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 - Naming conventions

Category - ABAP

How important is it nowadays to adhere to naming conventions or even to use naming conventions in the modern ABAP environment? We want to look at that in this article.

04/09/2021

ABAP - Use INSERT

Category - ABAP

APPEND already has a long history in ABAP, but this will play less and less of a role in the future. We'll show you why.

12/11/2020

ABAP Obsolete - Assignment and calculation

Category - ABAP

How does it actually work with the assignments and the calculation in ABAP? Here you will find out the current language constructs and what you should avoid.

06/26/2020

ABAP Obsolete - Ranges and Headers

Category - ABAP

Generate a decent range for an interface? Tables with or without header lines? We show you what is still possible and what you should rather be.

06/12/2020

ABAP Obsolete - DESCRIBE

Category - ABAP

Again we have for you a most used ABAP term for which there is already a new alternative, this time not just one alternative.

11/15/2019