在abap中(Clear,Free, Refesh)的用法
作者:互联网
文章目录
1. Introduction
The statements CLEAR, REFRESH, and FREE initialize data objects, that is, they set the content of a data object to an initial value.
2.Usage
2.1 Clear
Syntax
CLEAR dobj
Effect
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.
2.2 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.
2.3 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, 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.
3 Summarry
Clear and free are the same and we can initial any data object( types, instructure,variable,internal table) ,expect with herder line.( Clear itab[] = free itab).
Refersh is only for internal table and the usage is same with clear.
标签:itab,Clear,initial,Free,abap,internal,statement,memory,table 来源: https://blog.csdn.net/beyond911/article/details/121328267