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

Clear, refresh, free

Former Member
0 Likes
13,818

What is the effect of :

clear, refresh, free with internal table and

clear, refresh, free with workarea.

1 ACCEPTED SOLUTION
Read only

Former Member
5,306

Hi

refresh clears all the contents of an internal table ...

refresh : itab ...

clear : itab. <-- clears the header line

clear : itab{}. this is equivalent to refresh : itab.

free.. frees the memory allocation to the internal table ..

Reward if useful.

Regards,

Swetha.

Hi

refresh clears all the contents of an internal table ...

refresh : itab ...

clear : itab. <-- clears the header line

clear : itab{}. this is equivalent to refresh : itab.

free.. frees the memory allocation to the internal table ..

Reward if useful.

Regards,

Swetha.

8 REPLIES 8
Read only

valter_oliveira
Active Contributor
5,306

Hello.

Use CLEAR and FREE for workarea, and REFRESH and FREE for internal table.

Clear deletes the content of a work area, REFRESH deletes the lines of an internal table.

Now, the difference between FREE and the others, is in the fact that FREE liberts memory that was allocated for the internal table or workarea also. Instead, CLEAR and REFRESH only clear/delete it's contents.

Use FREE if you won't need an internal table/workarea more in the program.

Best regards.

Valter Oliveira.

Read only

Former Member
5,307

Hi

refresh clears all the contents of an internal table ...

refresh : itab ...

clear : itab. <-- clears the header line

clear : itab{}. this is equivalent to refresh : itab.

free.. frees the memory allocation to the internal table ..

Reward if useful.

Regards,

Swetha.

Read only

Former Member
0 Likes
5,306

Hi,

Clear internal table - (if with header line) just clears the workarea.

refresh internal table - deletes internal table contents. If with header line doesn't clear workarea.

free internal table - frees memory allocated to the internal table.

Cheers.

...Reward if useful.

Read only

0 Likes
5,306

Thanks one and all. Appreciate ur prompt reply.

I got the answer.

Read only

Former Member
0 Likes
5,306

Hi,

check out this link

reward if useful.

Read only

Former Member
0 Likes
5,306

hi

Clear will cleras the header information where as Refresh will also do same but it will remove all the BODY data available in internal table

CLEAR

Structures are set to their initial values component by component

means only header information

REFRESH

This statement sets an internal table itab to its initial value, meaning that it deletes all rows of the internal table. The memory space required for the table is freed up to the initial memory size INITIAL SIZE. For itab, you must specify an internal table.

To delete all rows and free the entire memory space occupied by rows, you can use the statement FREE.

The statement REFRESH itab acts for all internal tables like CLEAR itab[]. If an internal table itab has a header line, then the table body and not the header line is initialized. If the internal table itab has no header line, REFRESH itab acts like CLEAR itab. Therefore, you should always use CLEAR instead of REFRESH.

reward points if helpful

regards

mano

Read only

Former Member
0 Likes
5,306

e 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.

Example

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.

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.

reward points if helpful

Read only

Former Member
0 Likes
5,306

Hi,

Internal table:

CLEAR itab references an internal table itab with a header line, it only resets the subfields in the header entry to their initial valuesThe individual table entries remain unchanged.

To delete the entire internal table together with all its entries, you can use CLEAR .

*Refresh:*

The internal table itab is reset to its initial state, i.e. all table entries are deleted.

FREE:

If f is an internal table with header line (where the name f in a sense has two meanings) the statement FREE f refers to the body of the table, and the statement CLEAR f refers to the header line.

CLEAR ITAB.

REFRESH ITAB.