Sunteți pe pagina 1din 4

CLEAR vs. REFRESH vs.

FREE
25 may 2016
5:53

CLEAR vs. REFRESH vs. FREE


I almost forgot what does these 3 used for, basically they are used to initialize internal table.
1

1
2

CLEAR => Initialize the content and remain the allocated initial memory space, BUT,
because SAP allows using internal table(itab) with header line (enable you refer to structure and
internal table with the same name). CLEAR itab will only clear the header line not the table body. =>
clear the content of the structure.
To clear the table content, you need to use CLEAR itab[].
IF you declared it without header line (for instance, DATA lt_itab TYPE STANDARD TABLE
OF ever) CLEAR itab will clear the table content.
REFRESH => similar as CLEAR, but REFRESH always refer to internal table content (table body).
Thus, REFRESH itab =CLEAR itab[].
FREE => similar to REFRESH, always refer to internal table content, but it does one more thing, it
release the initial memory space allocated for the table body (table header is still exists). When you
try to fill in value to internal table again, new memory space will be allocated for the table body.

In Conclusion,

C1/Case 1: DATA: itab TYPE


STANDARD TABLE OF ever.

C2/Case
2: DATA: itab TYPE ever OCCURS 0
WITH HEADER LINE.

Refer to Work
Area / Structure
How to Initialize
table content

Refer to Tab
Content / Ta
Body

CLEAR

C1: CLEAR itab

C1:

C1:

C2: CLEAR itab[]

C2: CLEAR itab.

C2: CLEAR it

REFRESH

REFRESH itab

FREE

FREE itab

From <http://sap-isu-abap.blogspot.com/2010/01/clear-vs-refresh-vs-free.html>

CLEAR : It will clear only Header of the internal Table.

Refresh : It will clear the Data in that internal table,but allocated memory will
remain.

Free : It will clear the data as well as allocated memory for that internal table.

From <http://scn.sap.com/thread/314175>

CLEAR itab.

The memory space required for the table is released, except for the initial memory requirement.

If you are using internal tables with header lines, remember that the header line and the body of the table have the
same name. If you want to address the body of the table itself, not the header line, during initialization using CLEAR,
you must place two square brackets ([]) after the table name.

CLEAR itab[].

To ensure that the table itself has been initialized, you can use the statement

REFRESH itab.

This always applies to the body of the table. With REFRESH, too, the initial memory requirement fort he table
remains reserved. To release this memory space, use the statement

FREE itab.

You can use FREE to directly initialize an internal table and to release its entire memory space, including the initial
memory requirement, without first using the REFRESH or CLEAR statements. Like REFRESH, FREE accesses the
table body, not the table work area. After a FREEstatement, the internal table still exists. It still occupies the amount
of memory required for its header (currently 256 bytes). When you refill the table, the system has to allocate new
memory space to the lines.

From <http://scn.sap.com/thread/314175>

1. FREE Variable.

The memory allocated is refreshed and freed. Means after this statement the memory to the variable is no more. It
is freed from the program and can be used for some other program are purpose.

2. REFRESH i_tab.
Used for table to clear all the entries from the internal table body. but sill memory allocation exist and you can use
some other with in the program.

3. CLEAR variable .
it clears the memory of the variable i.e. variable will be empty.

4.DELETE variable or I_tab index i etc.


It deletes a specific value from a I_tab body based on condition.

From <https://scn.sap.com/thread/755805>

S-ar putea să vă placă și