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: 

diffrence

Former Member
0 Kudos

what is a diffrence between refresh,clear and free? plz give practial example

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

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

Regrds

2 REPLIES 2

Former Member
0 Kudos

Hi,

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

Regrds

0 Kudos

hi,

CLEAR : is used for initialization.When u clear any variable, work area they will come to their initial position.

REFRESH: will delete all the rows from internal table and will also clear the header of the internal table.

FREE: it free the memory alloted to internal table.and ur internal table will not exist in the memory area.

Reward the point if useful.

Regards,

Rajesh