abap clear refresh free用法区别

   在abap开发过程中,clear,refresh,free都有用来清空内表的作用,但用法还是有区别的。
    clear itab,清空内表行以及工作区,但保存内存区。
    clear itab[],清空内表行,但不清空工作区,但保存内存区。
    refresh itab,与clear itab[]相似,只清空内表行,但保存内存区。
    free itab,与refresh相似,清空内表行,但不清空工作区,且释放内存区域。


clear 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.

----------------------------------------------------------------------
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.
----------------------------------------------------------------------
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, 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.
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.






猜你喜欢

转载自caoxuhuan.iteye.com/blog/908860