‎2007 Jun 11 10:56 AM
hi friends,
any one can tell me the difference between clear,refresh and free keywords which are used in internal tables.
‎2007 Jun 11 10:57 AM
Hi
Clear: clears the Header of the Itab
REFRESH: removes the Body of the ITAB
FREE: removes the header, Body of the ITab and even from the Memory
<b>
Reward points for useful Answers</b>
Regards
Anji
‎2007 Jun 11 10:57 AM
HI,
clear means clearing the header part of the internal table
clear[] means clearing the body of the internal table
refresh means clearing the body of the internal table
and free means deallocating the memory of the internal table
reward points if helpful
regards,
venkatesh
‎2007 Jun 11 10:58 AM
Hi Varad,
Clear - Mostly to clear work area of table, can clear the table data also if given with []
refresh - to clear the whole table data
free - to free the memory allocated to the table.
Reward points if useful.
Regards,
Atish
‎2007 Jun 11 10:59 AM
Hi,
CLEAR resets to its initial values..
1.
For structure it will clear all the fields in the structure..
EX:
DATA: S_MARA LIKE MARA.
CLEAR: S_MARA.
2. For internal tables if it is declared with header line then it clear the header line otherwise it will clear the whole internal table..
EX:
DATA: ITAB TYPE STANDARD TABLE OF MARA WITH HEADER LINE.
CLEAR: ITAB.. " THis will clear the header line..
DATA: ITAB TYPE STANDARD TABLE OF MARA.
CLEAR: ITAB.. " THis will clear the whole internal table..
3. Refresh clear the internal tables irrespective of with or without header line.
4. Clear can be used for variables, work areas and internal tables..
Check this sample code:
REPORT ypra_sample61.
TYPES: BEGIN OF ty_itab,
data1 TYPE char10,
data2 TYPE char10,
END OF ty_itab.
DATA: itab TYPE STANDARD TABLE OF ty_itab,
wa_itab TYPE ty_itab.
DATA: itab1 TYPE ty_itab OCCURS 0 WITH HEADER LINE,
wa_itab1 TYPE ty_itab.
wa_itab-data1 = '12'.
wa_itab-data2 = '112'.
APPEND wa_itab TO itab.
CLEAR: wa_itab, itab.
*Here the clear will clear both the header and as well as Body - Because
*it is declared as type standard table of ty_itab.
wa_itab1-data1 = '12'.
wa_itab1-data2 = '112'.
APPEND wa_itab1 TO itab1.
CLEAR: wa_itab1, itab1.
REFRESH: itab1.
*Here both the clear & refresh should be given to clear the workarea & *the internal table
<b>*Reward points</b>
Regards
null
‎2007 Jun 11 10:59 AM
Hi Varadarajan ,
Clear : This is used for work area or header lines of the internal tables , so when you use the clear command it clears the header to the workarea , but the content of the internal table remains intact and do not get refreshed.
So in order to delete the entries in the internal table you need to use the Refresh command,
Free is used to free the memory allocated to the internal table,.
Hope this helps.
Regards
Arun
Assign point for helpful answers
‎2007 Jun 11 11:01 AM
hi,
clear -> used for internal tables [both for header area and body ]
ex: clear itab -> clears the work area.
clear itab[] -> clears the body of internal table itab.
refresh -> used to clear the worharea of an internal table.
ex: refresh itab -> clears the work area.
free -> used to free up the memory space occupied by internal tables.
ex: free iatb.
if helpful reward some points.
with regards,
suresh.
‎2007 Jun 11 11:04 AM
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
FREE <itab>.
You can use FREE to initialize an internal table and release its memory space without first using
the REFRESH or CLEAR statement. Like REFRESH, FREE works on the table body, not on the
table work area. After a FREE statement, you can address the internal table again. 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,
Bhaskar
‎2007 Jun 11 11:05 AM
hi,
chk this link.
http://help.sap.com/saphelp_nw2004s/helpdata/en/fc/eb384e358411d1829f0000e829fbfe/content.htm
Rgds
Anversha
‎2007 Jun 13 9:54 PM
clear:refreshes header
refresh:just tempararily refresh the content but actually the data is not erased from database
free:it frees the memory allocated by the data from the database server also