Application Development 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: 

free or refresh and clear

Former Member
0 Kudos
109

Hi,

i wont to clean all internal table what is recommended to use free or refresh and clear (for header).

Regards

1 ACCEPTED SOLUTION

former_member387317
Active Contributor
0 Kudos
65

Hi Ricardo,

Please Go through below information on when to use these statements and choose appropriate for your requirement...

Ultimately indepth knowledge is better ...

and If you want to delete just internal table body then use refresh itab.

or

clear itab[].

nd want to clear itab nd deallocate the memory also then

Free itab.

or

if you just want to clear header line then

clear itab.

==========================================

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

refresh should use only internal table,clear - you can use variables,internal table ,work areas

FREE : it is deallocating meomry .. so this memory can be utilize by other program..

Hope it will solve your problem...

Reward points if useful..

Thanks & Regards

ilesh 24x7

7 REPLIES 7

Former Member
0 Kudos
65

hi,

clear is recomended,

generally we clear the work areas.

reward if useful

Former Member
0 Kudos
65

Header table clearing:

CLEAR: it_tab, it_tab[].

or

CLEAR it_tab.

REFREAH it_tab.

Non Header Tables

REFRESH it_tab.

FREE is for releasing memory.

Former Member
0 Kudos
65

Hi friend,

Use FREE itab....it will release the memory space too....

Refer this link:

http://help.sap.com/saphelp_nw70/helpdata/EN/fc/eb384e358411d1829f0000e829fbfe/frameset.htm

Former Member
0 Kudos
65

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

Former Member
0 Kudos
65

Hi,

CLEAR is used if you want to remove only the Header Line of an internal table.

Refresh is used if you want to delete the header line as well as all the values or records present in internal table.

So , usually for work areas and variables Clear is enough. Refresh doesnt make sense here, with variables and work areas.

What Free does is, it clears the value and sets the value to its INITIAL value.

Reward if helpful.

Regards.

Former Member
0 Kudos
65

Hi,

Refresh will delete all data present in the internal table.

free will delete the data and deallocate the memory of the internal table.

You can choose either of them.

Thanks,

Sriram Ponna.

former_member387317
Active Contributor
0 Kudos
66

Hi Ricardo,

Please Go through below information on when to use these statements and choose appropriate for your requirement...

Ultimately indepth knowledge is better ...

and If you want to delete just internal table body then use refresh itab.

or

clear itab[].

nd want to clear itab nd deallocate the memory also then

Free itab.

or

if you just want to clear header line then

clear itab.

==========================================

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

refresh should use only internal table,clear - you can use variables,internal table ,work areas

FREE : it is deallocating meomry .. so this memory can be utilize by other program..

Hope it will solve your problem...

Reward points if useful..

Thanks & Regards

ilesh 24x7