Entering content frameInitializing Internal Tables Locate the document in its SAP Library structure

initiale Speicheranforderung

Like all data objects, you can initialize internal tables with the

CLEAR <itab>.

statement. This statement restores an internal table to the state it was in immediately after you declared it. This means that the table contains no lines. However, the memory already occupied by the memory up until you cleared it remains allocated to the table.

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 in a comparison, you must place two brackets ([ ]) after the table name.

CLEAR <itab>[].

To ensure that the table itself has been initialized, you can use the

REFRESH <itab>.

statement. This always applies to the body of the table. As with the CLEAR statement, the memory used by the table before you initialized it remains allocated. To release the memory space, use the statement

FREE <itab>.

You can use FREE to initialize an internal table and release its memory space without first using the REFRESH or CLEAR statement. Like REFRESH, FREE works on the table body, not on the table work area. After a FREE statement, you can address the internal table again. 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.

Example

DATA: BEGIN OF LINE,
COL1,
COL2,
END OF LINE.

DATA ITAB LIKE TABLE OF LINE.

LINE-COL1 = 'A'. LINE-COL2 = 'B'.

APPEND LINE TO ITAB.

REFRESH ITAB.

IF ITAB IS INITIAL.
WRITE 'ITAB is empty'.
FREE ITAB.
ENDIF.

The output is:

ITAB is empty.

In this program, 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.

 

 

 

 

 

Leaving content frame