about refresh/clear/free

REFRESH
Syntax
REFRESH itab.
Effect
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.
Note
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.
Exceptions
Non-Catchable Exceptions
Cause: No more memory space available to create the table
Runtime Error: REFRESH_NO_SHORT_MEMORY

CLEAR
Syntax
CLEAR dobj [ {WITH val [IN {BYTE|CHARACTER} MODE] }
           | {WITH NULL} ].
Extras:
1. ... WITH val [IN {BYTE|CHARACTER} MODE]
2. ... WITH NULL
Effect
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.
Note
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.

Addition 1
... WITH val [IN {BYTE|CHARACTER} MODE]
Effect
If you use the WITH val addition and specify BYTE or CHARACTER MODE, all spaces are replaced either with the first byte or the first character in val. If dobj is of the type string or xstring (as of Release 6.10), the string is processed in its current length.
The IN BYTE and CHARACTER MODE additions can be used as of Release 6.10 (see also Processing Byte Strings and Character Strings ). Without specification and before Release 6.10 the IN CHARACTER MODE addition applies. Depending on the addition, the data object dobj must be either byte-type or character-type and the data object val must be either byte-type or character type and have the length 1. Before Release 6.10, dobj and val must be flat. If dobj and val do not have the correct type and correct length in a non- Unicode program, they are still handled as if they do, independently of the actual type. In Unicode programs, this will cause a Syntax error or an exception that cannot be handled.
Example
The byte string hexstring as assigned a specific byte value over the entire current length.
DATA: hexstring TYPE xstring,
      hex(1)    TYPE x VALUE 'FF'.
...
hexstring = '00000000'.
...
CLEAR hexstring WITH hex IN BYTE MODE.

Addition 2
... WITH NULL
Effect
This addition, which is not allowed in ABAP Objects, replaces all bytes of dobj with the value
hexadecimal 0. In this case, the data object dobj must be flat.
Note
The WITH NULL addition should only be used for byte-type data objects and therefore be replaced with the CLEAR WITH val addition, which - in this context - at least ensures a higher level of security in Unicode programs.
Exceptions
Non-Catchable Exceptions
Cause: Field val does not have length 1 for variant CLEAR fld WITH val IN BYTE MODE.
Runtime Error: CLEAR_VALUE_BYTEMODE_WRONG_LEN
Cause: Field val does not have length 1 for variant CLEAR fld WITH val [IN CHARACTER MODE].
Runtime Error: CLEAR_VALUE_WRONG_LENGTH

FREE
Syntax
FREE dobj.
Effect
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. It releases the entire memory area occupied by the table rows. If dobj is a structure with table-like components, the memory of each table-like component is released.
Note
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.
 

你可能感兴趣的:(refresh)