2008 Feb 19 12:23 PM
When copying from one itab to another (consider here itab1,itab2
Itab1
{
x,
y,
z.
}
itab2
{
a,
b,
c,
}
Can we use move or better
to use ...
loop itab1.
Refresh itab2.
clear itab2.
itab2-a =itab1-x.
.
.
.
End loop.
For this do we need to add refresh clear or simply ignore.
What is the exact purpose of refresh and clear here
2008 Feb 19 12:26 PM
Hi Sunil,
clear:
Resets the contents of f to its initial value.
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
Refresh:
The internal table itab is reset to its initial state, i.e. all table entries are deleted.
Regards,
Chitra
When copying from one itab to another (consider here itab1,itab2
Itab1
{
x,
y,
z.
}
itab2
{
a,
b,
c,
}
Can we use move or better
to use ...
loop itab1.
Refresh itab2.
clear itab2.
itab2-a =itab1-x.
.
.
.
End loop.
For this do we need to add refresh clear or simply ignore.
What is the exact purpose of refresh and clear here
2008 Feb 19 12:25 PM
Please use linke for information
http://help.sap.com/saphelp_nw70/helpdata/en/fc/eb384e358411d1829f0000e829fbfe/content.htm
Thanks,
2008 Feb 19 12:26 PM
Hi Sunil,
clear:
Resets the contents of f to its initial value.
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
Refresh:
The internal table itab is reset to its initial state, i.e. all table entries are deleted.
Regards,
Chitra
2008 Feb 19 12:27 PM
Refresh : refreshes the entries of the particular internal table ..
clear : clears header line ..
clear[] similar to refresh ..
Below don't use refresh between loop .. endloop ...
loop itab1.
*Refresh itab2.
itab2-a =itab1-x.
.
.
.
append itab2.
clear itab2.
End loop
2008 Feb 19 12:27 PM
It is better to add refresh no need of clear for tables
This condition is to avoid overlapping of data
Never use Refresh inside loop
loop itab1.
Refresh itab2.
clear itab2.
itab2-a =itab1-x.
.
.
.
End loop.
It is totally wrong user it before loop
hear you are adding data and at same time clearing it so wrong
Refresh itab2.
loop itab1.
itab2-a =itab1-x.
.
.
.
End loop.
2008 Feb 19 12:27 PM
Hi,
Refresh is used to clear the interanal table
clear is used to clear the field string
see if u have internal table itab and it has a work area also with the same name
then if u write
refresh itab.
it clears the internal table completely
and if u write
clear itab.
it clears the field string completly and not at all touches the internal table.
<REMOVED BY MODERATOR>
in adtion u can write
clear itab [ ] .
it clears the internal table only i think now u got the solution....
Edited by: Alvaro Tejada Galindo on Feb 19, 2008 5:07 PM
2008 Feb 19 12:29 PM
Clear will suffice. refresh will clean up the whole internal table data
2008 Feb 19 12:30 PM
Hi,
Refresh statement will clear the data that is present in internal table.
Anc clear will delete the data that is present in the header line.
Thanks
Sriram Ponna.
2008 Feb 19 12:31 PM
hi,
refresh deletes all table lines .Storage space is not released
CLEAR IT | CLEAR IT[]
IT Internal Table
Statement IT With header line IT Without header line
clear it Clears the header line Deletes all rows of IT
clear it[] Deletes all rows of IT Deletes all rows of IT
here is an example.
DATA : BEGIN OF LINE,
COL1 TYPE C,
COL2 TYPE I,
END OF LINE.
DATA TAB1 LIKE LINE OCCURS 10 with header line.
LINE-COL1 = A. LINE-COL2 = 2.
APPEND LINE TO TAB1.
LINE-COL1 = B. LINE-COL2 = 1.
APPEND LINE TO TAB1.
CLEAR TAB1.
REFRESH TAB1.
IF TAB1 IS INITIAL. WRITE:/ TAB1 IS EMPTY. FREE TAB1. ENDIF.
regards,
sreelakshmi
2008 Feb 19 12:35 PM
Hi,
" REFRESH : itab " stmt is used to delete all the contents in the internal table itab.After this stmt no data will be stored in this internal table and now you can use this internal tbale to fill other processed data / for processing in another way.
CLEAR : itab is used clear the header line of the internal table.
When we are using Loop and filling internal table from other internal table or from some other varibales better to clear the header line part so that if data is present for the previous record at header level of that internal table, and for the current record processing if no data is available for that field means you will get previous record data stored in that field into current record.
itab
F1 F2
Headerlevel 10 A
We use append stmt to insert record from header level to body level and then we use clear to clear header level data to process nect loop / to insert next record.
Now we have data for the 2 fields in the internal table itab.
itab
F1 F2
Headerlevel 20
Suppose if you dont have data for F2 field then if we dont use clear there is a chance of getting A into this record also.Which is incorrect data.
Memory allocated to this internal table will not freed until you use "FREE : itab " .
Regds
Parvathi
<REMOVED BY MODERATOR>
Edited by: Alvaro Tejada Galindo on Feb 19, 2008 5:08 PM
2008 Feb 19 12:35 PM
refresh itab=> deletes all rows from internal table where as the mamory will persist.
refresh only used for internal tables not for workareas.
whereas clear used for both internal tables and work areas.
clear itab=> deletes only header information
clear itab[]=> deletes all table information.
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |