Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

difference between refresh and clear[] .

Former Member
0 Likes
15,101

what is the main difference between refresh and clear [ ] and free.

8 REPLIES 8
Read only

Former Member
0 Likes
6,949

Refresh will clear the header line and the body of an internal table.

Clear will clear only the header if used on an internal table with a header line. On other variables, it will clear the contents.

Free will refresh the internal table and release the memory associated with it.

Read only

Former Member
0 Likes
6,949

Rajesh,

Just Consider all below cases for internal table

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.

Pls. Mark if clear

Read only

Former Member
0 Likes
6,949

Hi

Initializing Internal Tables

Like all data objects, you can initialize internal tables with the

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, FREEaccesses 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.

Regards

Shiva

Read only

Former Member
0 Likes
6,949

hi,

REFRESH - Clears the contents of the internal table (i.e., the records in the internal table will be deleted).

CLEAR - Clear the contents of the internal table with respect to internal table without header line. Incase of internal table with header line it clears only header line. If you want to clear the contents of the internal table with header line then you can use CLEAR[], which clears the body of the internal table with header line and not the header.(CLEAR[] is same like REFRESH)

FREE - Clears the memory occupied by the internal table.

Read only

Former Member
0 Likes
6,949

hi,

CLEAR <itab>.

statement. This statement restores an internal table to the state it was in immediately after you

declared it. This means that the table contains no lines. However, the memory already occupied

by the memory up until you cleared it remains allocated to the table.

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 in a comparison, you

must place two brackets ([ ]) after the table name.

CLEAR <itab>[].

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

REFRESH <itab>.

statement. This always applies to the body of the table. As with the CLEAR statement, the

memory used by the table before you initialized it remains allocated. To release the memory

space, use the statement

hope this helps

regards.

Read only

0 Likes
6,949

To ensure that the table itself has been initialized.

can u give an example that what a table itself initialized.

Read only

0 Likes
6,949

Hi rajesh,

<b>To ensure that the table itself has been initialized, you can use the statement</b>

REFRESH itab.

REPORT demo_int_tables_clear.

DATA: BEGIN OF line,

col1(1) TYPE c,

col2(1) TYPE c,

END OF line.

DATA itab LIKE TABLE OF line.

line-col1 = 'A'. line-col2 = 'B'.

APPEND line TO itab.

REFRESH itab.

IF itab IS INITIAL.

WRITE 'itab is empty'.

FREE itab.

ENDIF.

The list output is:

itab is empty.

<b>An internal table itab is filled and then initialized with REFRESH. The IF statement uses the expression itab IS INITIAL to find out whether itab is empty. If so, the memory is released.</b>

Read only

Former Member
0 Likes
6,949

Hi rajesh,

<b>1. Clear ITAB : This Statement will clear the Internal Table Header content.

To clear the Intertal Table Header as well Body we can use Clear ITAB [ ] statement.

2. Refresh will deletes the Internal Table content but still memory is not freed.

3. Free statement is used to deallocate the memory of internal table

Free itab :This statement is used to deallocate the memory of internal table itab

</b>