Entering content frame

Determining the Attributes of Internal Tables Locate the document in its SAP Library structure

To find out the attributes of an internal table at runtime that were not available statically, use the statement:

DESCRIBE TABLE itab [LINES lin] [OCCURS n] [KIND knd].

If you use the LINES parameter, the number of filled lines is written to the variable lin. If you use the OCCURS parameter, the value of the INITIAL SIZEof the table is returned to the variable n. If you use the KIND parameter, the table type is returned to the variable knd: ‘T’ for standard table, ‘S’ for sorted table, and ‘H’ for hashed table.

Example

REPORT demo_int_tables_describe_table .

DATA: BEGIN OF line,
        col1 TYPE i,
        col2 TYPE i,
      END OF line.

DATA itab LIKE HASHED TABLE OF line WITH UNIQUE KEY col1
                                    INITIAL SIZE 10.

DATA: lin    TYPE i,
      ini    TYPE i,
      knd(1) TYPE c.

DESCRIBE TABLE itab LINES lin OCCURS ini KIND knd.
WRITE: / lin, ini, knd.

DO 1000 TIMES.
  line-col1 = sy-index.
  line-col2 = sy-index ** 2.
  INSERT line INTO TABLE itab.
ENDDO.

DESCRIBE TABLE itab LINES lin OCCURS ini KIND knd.
WRITE: / lin, ini, knd.

The list output is:

         0         10  H

     1,000         10  H

Here, a hashed table itab is created and filled. The DESCRIBE TABLE statement is processed before and after the table is filled. The current number of lines changes, but the number of initial lines cannot change.

 

 

Leaving content frame