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: 

what is the main deference in free, refresh,clear?

Former Member
0 Kudos

what is the main deference in free, refresh,clear,

and how to deffer defferent tables like cluster, pooled,Trasparent ?

11 REPLIES 11

SantoshKallem
Active Contributor
0 Kudos

Pooled table

Pooled tables can be used to store control data (e.g. screen sequences,

program parameters or temporary data). Several pooled tables can be

combined to form a table pool. The table pool corresponds to a physical

table on the database in which all the records of the allocated pooled

tables are stored.

Cluster table

Cluster tables contain continuous text, for example, documentation.

Several cluster tables can be combined to form a table cluster. Several

logical lines of different tables are combined to form a physical record

in this table type. This permits object-by-object storage or

object-by-object access. In order to combine tables in clusters, at least

parts of the keys must agree. Several cluster tables are stored in one

corresponding table on the database.

Transparent table

There is a physical table on the database for each transparent table. The

names of the physical tables and the logical table definition in the

ABAP/4 Dictionary correspond.

All business data and application data are stored in transparent tables.

FREE

The FREE statement has the same effect as the CLEAR

statement for any data objects except internal tables.

For internal tables, FREE has the same effect as the REFRESH statement, though the entire memory area occupied by the table rows is released, and the initial memory area remains unoccupied. If dobj is a structure with table-like components, the memory of each table-like component is released.

TYPE THE KEYWORD IN EDITOR AND PRESS F1 ON IT.

U'L BE CLEARED U R DOUBTS

santhosh reddy

Former Member
0 Kudos

hi

<u><b>FREE</b></u>

FREE dobj.

The FREE statement has the same effect as the CLEAR

statement for any data objects except internal tables.

For internal tables, FREE has the same effect as the REFRESH statement, though the entire memory area occupied by the table rows is released, and the initial memory area remains unoccupied. If dobj is a structure with table-like components, the memory of each table-like component is released.

If dobj is an internal table with a header line, FREE has the same effect as REFRESH on the table body, and not the header line.

<u><b>REFRESH</b></u> itab.

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.

<u><b>CLEAR dobj</b></u> [ {WITH val [IN {BYTE|CHARACTER} MODE] }

| {WITH NULL} ].

1. ... WITH val [IN {BYTE|CHARACTER} MODE]

2. ... WITH NULL

Without the optional additions, the data object dobj is assigned the type-specific initial value. The following applies:

The initial values are assigned to elementary data types according to the table of built-in ABAP types.

Reference variables are assigned null references.

Structures are set to their initial values component by component.

All rows in an internal table are deleted. All the memory required for the table, except for the initial memory requirement, is released (see Declaring Internal Tables). The FREE statement is used to release the memory space occupied by the rows of internal tables.

The optional additions allow you to fill the spaces of a data object with other values than the initial value.

If dobj is an internal table with a header line, you must specify dobj[] to delete the rows, otherwise only the header line will be deleted.

REWARD IF USEFULL

Former Member
0 Kudos

JozsefSzikszai
Active Contributor
0 Kudos

hi phani,

CLEAR : sets the variable/structure to its initial value. In case of internal tables: w/o hedaer line: deletes the lines of the internal table, internal table with header line: deletes the header line, if you want to delete the lines of internal table, than you have to use: CLEAR itab[]

FREE : works like CLEAR, but not for internal tables (anything else)

REFRESH : only for internal tables , works like CLEAR itab[]

hope this helps

ec

varma_narayana
Active Contributor
0 Kudos

Hi Phani..

Clear ITAB[].

or

REFRESH ITAB.

Both Above statements will delete the Data from internal table (body) .

But the Memory is still allocated.

FREE ITAB.

This statement will Deallocate the Memory of Internal Table along with deletion of Records.

<b>Reward if Helpful.</b>

0 Kudos

Hi,

Both CLEAR naf REFRESH behaviour is same for TABLE WITH OUT HEADER LINE.

For a TABLE WITH HEADER LINE if you use

CLEAR: ITAB, it clears header line, but table is there you need to use

CLEAR: itab[].

If you use REFRESH: ITAB it clears only the Table not the header line, you have to use CLEAR: itab to clear the header line.

FREE: clears the data and frees the memory allocated too.

Regards,

Sesh

Former Member
0 Kudos

Hello Phani,

free-- Reset to appropriate initial value for type, including release

of resources

clear --- initial value qwill be assigned to the variables. u can clear strcutre and headers of internal table as well

refresh---- clears body of intrernal table...

more details are given bellow...

<b>FREE</b>...

Reset to appropriate initial value for type, including release

of resources

- FREE f.

Release an area in the ABAP/4 memory

- FREE MEMORY.

Release the memory occupied by an external object

- FREE OBJECT obj.

<b> CLEAR</b>

Basic form CLEAR f.

Additions:

1. ... WITH g

2. ... WITH NULL

Effect Resets the contents of f to its initial value.

<b>REFRESH</b> - Delete an internal table

Variants:

1. REFRESH itab.

2. REFRESH itab FROM TABLE dbtab.

3. REFRESH itab FROM SELECT-OPTIONS.

Variant 1 REFRESH itab.

Effect The internal table itab is reset to its initial state, i.e.

all table entries are deleted.

The return code SY-SUBRC is undefined

Notes - The header entry of a table with a header line remains

unchanged. It can be reset to its initial value using

CLEAR.

- FREE itab can be used to free up the memory allocated to

the table.

Variant 2 REFRESH itab FROM TABLE dbtab.

Note This variant is no longer maintained and should no longer be

used (see also obsolete key words). Please use the SELECT ...

INTO TABLE statement instead.

Effect The internal table itab is deleted and it is then filled with

the contents of the database table dbtab.

A generic argument can be used to specify a restriction to a

particular part of the database table when filling (LOOP AT

dbtab, READ TABLE dbtab).

The table dbtab must be declared in the program using TABLES.

The return code SY-SUBRC is undefined

Example Delete an internal table MESSAGES, then fill the table with

all messages from the table T100 with language key 'D' and ID

'RF'.

TABLES T100.

DATA MESSAGES TYPE TABLE OF T100 WITH HEADER LINE

MESSAGES-TEXT = 'Delete me'.

APPEND MESSAGES.

T100-SPRSL = 'E'.

T100-ARBGB = 'RF'.

REFRESH MESSAGES FROM TABLE T100.

Variant 3 REFRESH itab FROM SELECT-OPTIONS.

Note This variant is no longer supported (see also obsolete key

words). The equivalent functionality is now available in the

function module RS_REFRESH_FROM_SELECTOPTIONS.

Effect Deletes the internal table itab and then transfers the

database selections and the selection parameters together with

the values entered by the user.

Notes Performance:

The runtime required to delete an internal table depends on

the amount of memory previously occupied by that table.

Resetting a small internal table takes around 15 msn (standard

microseconds). Resetting a 200 KB table takes around 400 msn,

and a 1 MB table, around 3000 msn.

If the internal table has an index or a hash table (because it

was edited using INSERT, DELETE, SORT or COLLECT), the runtime

increases slightly, since the index or hash table has to be

released as well as the table itself.

Notes Runtime errors:

REFRESH_NO_SHORT_MEMORY: No more memory available to create

the table.

For predefined types (see DATA), the following initial values

are used:

Type C: ' ... ' (blank character)

Type N: '00...0'

Type 😧 '00000000'

Type T: '000000'

Type I: 0

Type P: 0

Type F: 0.0E+00

Type X: 0

Type STRING: '' (empty string)

Type XSTRING: '' (empty byte sequence)

If f is a field string, each component field is reset to its

initial value. If it is an internal table without a header

line, the entire table is deleted together with all its

entries. If, however, f is an internal table with a header

line, only the sub-fields in the table header entry are reset

to their initial values.

Example

DATA: TEXT(10) VALUE 'Hello',

NUMBER TYPE I VALUE 12345,

ROW(10) TYPE N VALUE '1234567890',

BEGIN OF PLAYER,

NAME(10) VALUE 'John',

TEL(8) TYPE N VALUE '08154711',

MONEY TYPE P VALUE 30000,

END OF PLAYER.

...

CLEAR: TEXT, NUMBER, PLAYER.

The field contents are now as follows:

ROW = '1234567890'

TEXT = ' '

NUMBER = 0

PLAYER-NAME = ' '

PLAYER-TEL = '00000000'

PLAYER-MONEY = 0

Notes 1. When CLEAR itab references an internal table itab with a

header line, it only resets the sub-fields in the header

entry to their initial values (as mentioned above). The

individual table entries remain unchanged.

To delete the entire internal table together with all its

entries, you can use CLEAR itab[] or REFRESH itab.

2. Within a logical expression, you can use f IS INITIAL to

check that the field f contains the initial value

appropriate for its type.

3. Variables are normally initialized according to their type,

even if the specification of an explicit initial value

(addition "... VALUE lit" of the DATA statement) is

missing. For this reason, it is not necessary to initialize

variables again with CLEAR after defining them.

Addition 1 ... WITH g

Effect The field f is filled with the value of the first byte of the

field g.

Addition 2 ... WITH NULL

This addition is not allowed in an ABAP Objects context. See

CLEAR WITH NULL not allowed.

Effect Fills the field with hexadecimal zeros.

Note You should use this addition with particular care because the

fields of most data types thus receive values which are really

invalid.

Note Performance:

The runtime required to reset a field, a structure or the

header line of an internal table increases with the size of

the object. Resetting a field with type C and length 10 takes

about 3 msn (standard microseconds); with length 100, this is

around 8 msn, and with length 10000 around 60 msn.

Additional help Resetting Fields to Initial Values

Initializing Internal Tables

Reward If Useful.

Regards

--

Sasidhar Reddy Matli.

Former Member
0 Kudos

hai

clear : clears only work area(header line)

refresh: clears the body of the internal table.

free : clears both header line and body of the internal table.

ragards

ramesh.

Former Member
0 Kudos

in short ,

clear clears the header line.

refresh clears body of internal table

free clears the memory from apllication server.

refresh = clear[].

REWARD ME IF USEFUL.

former_member402443
Contributor
0 Kudos

Difference between Clear,Refresh and Free.

CLEAR <internal table> statement

Initialises the header line.

Internal table lines remain unchanged.

REFRESH<internal table> statement

Deletes all able lines.

Storage space is not released.

Paging is released.

Header line remains unchanged.

FREE<internal table>

Deletes all table lines.

Storage space is released.

Header line remains unchanged.

The CLEAR <internal table> statement initialises all single fields in the header line of an internal table according to type.

The REFRESH <internal table> statement deletes all table lines. The table storage space is not released. The header line remains unchanged.

The FREE <internal table> statement releases the storage space required for a table. The header line remains unchanged.

This statement is particularly useful for very large internal tables. You can improve a program’s performance by ‘freeing’ the memory space allocated for the internal table.

Internal tables that are local to a subroutine are automatically ‘freed’ upon leaving the subroutine.

Difference between cluster,pooled and Transparent Tables

Transparent Table:

In SAP R/3, aside from a few exceptions, the only way to access the database system and the tables within the database is via the ABAP/4 Data Dictionary interface.

For the majority of the tables, the ABAP/4 Data Dictionary provides a fully transparent interface to the database. This means all of the fields of a Dictionary table correspond to a field in the real database table. Since the data structure is visible in the Dictionary corresponds entirely to the structure of the table created by the database system, these tables are called transparent tables. A transparent table is a normalized table. SAP is slowly evolving all R/3 tables into transparent tables.

Pooled Tables:

Different tables which are not linked to each other with a common key can be combined into a Table Pool. The tables contained within this pool are called Pooled Tables. A table pool is stored in the database a simple table. The table's data sets contain, in separate fields, the actual key for the data set to be stored, the name of the pooled table and the contents of the data set to be stored.

Using this schema, several logical tables are combined into a single real database table. Although the data structure of each set is lost during the write to the table pool, it is restored during the read by the ABAP/4 Data Dictionary. The ABAP/4 Data Dictionary utilizes its meta-data to accomplish this.

Since information must be prepared (defined) within the ABAP/4 Data Dictionary when it is read or written to (or accessed), this process itself defines these as not transparent tables.

Cluster Tables :

Occasionally, several tables may be linked by a common key. The ABAP/4 Data Dictionary can also combine these tables into a single table. Each data set of the real table within the database contains a key and in a single data field, several data sets of the subsequent table for this key.

As mentioned above, these table types require special data handling, therefore they are not transparent tables.

Note: Both Pooled and Cluster Tables are stored as tables within the database. Only the structures of the two table types which represent a single logical view of the data are defined within the ABAP/4 Data Dictionary. The data is actually stored in bulk storage in a different structure. These tables are commonly loaded into memory (i.e., 'buffered') due to the fact they are typically used for storing internal control information and other types of data with little or no external (business) relevance.

Reward points if useful

Regards

Manoj Kumar

Former Member
0 Kudos

Hi,

Let us follow with an internal (ITAB) with header line.

CLEAR ITAB. clears only the heade line.

REFRESH ITAB. clears body of the internal table but not header line.

FREE ITAB: it deallocates the memory of the ITAB and header line remains unchanged means values brought up in the header will not be cleared or deleted.

Now let us follow with the a internal table with out header line.

CLEAR ITAB. clears all the contents of the intranal table since it does not have header line.

and REFRESH and FREE works as above .

Now the point is when to use clear , refresh and free.

Clear:for each time you loop the internal table clear the header line before it goes to the next loop so that you wont get previous values into the next record.

Refresh: If you are done with an internal table and you want some other data into the same table then refesh the internal table and get othe data.

Free: If you are done with the internal table and further you have nothing to do with that interanl table then use free statement so that the memory will be deallocated for that table.

For pooled and cluster table difference you have got lot of solutions.

Regards,

Nageswar.