Like all data objects, you can initialize internal tables with the
The memory space required for the table is released, except for the initial memory requirement.
If you are using internal tables with header lines, remember that the header line and the body of the table have the same name. If you want to address the body of the table itself, not the header line, during initialization using CLEAR, you must place two square brackets () after the table name.
To ensure that the table itself has been initialized, you can use the statement
This always applies to the body of the table. With REFRESH, too, the initial memory requirement fort he table remains reserved. To release this memory space, use the statement
You can use FREE to directly initialize an internal table and to release its entire memory space, including the initial memory requirement, without first using the REFRESH or CLEAR statements. Like REFRESH, FREEaccesses the table body, not the table work area. After a FREEstatement, the internal table still exists. It still occupies the amount of memory required for its header (currently 256 bytes). When you refill the table, the system has to allocate new memory space to the lines.
DATA: BEGIN OF line,
col1(1) TYPE c,
col2(1) TYPE c,
END OF line.
DATA itab LIKE TABLE OF line.
line-col1 = 'A'. line-col2 = 'B'.
APPEND line TO itab.
IF itab IS INITIAL.
WRITE 'itab is empty'.
The list output is:
itab is empty.
An internal table itab is filled and then initialized with REFRESH. The IF statement uses the expression itab IS INITIAL to find out whether itab is empty. If so, the memory is released.