DESCRIBE TABLE

Short Reference

Syntax

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

Extras:

1. ... KIND knd

2. ... LINES lin

3. ... OCCURS n

Effect

This statement determines some properties of the internal table itab and assigns them to the specified variables. The various additions enable you to determine the table type, the number of currently filled rows and the initial memory requirement.

In addition, the system fields sy-tfill and sy-tleng are filled with the current number of table rows and the length of a table row in bytes.

Notes

Addition 1

... KIND knd

Effect

The table type of the internal table itab is determined and a corresponding one-digit identification is assigned to the data object knd. A character-type data type is expected for the data object. The identifications are "T" for standard tables, "S" for sorted tables and "H" for hashed tables. These values are also defined as constants sydes_kind-standard, sydes_kind-sorted, and sydes_kind-hashed in the type group SYDES.

Addition 2

... LINES lin

Effect

The current number of table rows of the internal table itab is determined and is assigned to the data object lin.The data type i is expected for the data object.

Note

As of release 6.10, the current number of rows of an internal table can also be determined using the in-built function lines.

Addition 3

... OCCURS n

Effect

The initial memory requirement defined during the creation of the internal table with the addition INITIAL SIZE or the obsolete addition OCCURS is determined and assigned to the data object n. The data type i is expected for the data object.

Example

Descending sorting of a generically typed internal table in a subprogram. Since sorted tables cannot be sorted in a descending order, the table type is checked to avoid an exception that cannot be handled.

TYPE-POOLS sydes.
...
FORM sort_descending CHANGING itab TYPE ANY TABLE.
  DATA tabkind(1) TYPE c.
  DESCRIBE TABLE itab KIND tabkind.
  IF tabkind = sydes_kind-standard OR
     tabkind = sydes_kind-hashed.
    SORT itab DESCENDING.
  ELSEIF tabkind = sydes_kind-sorted.
    MESSAGE '...' TYPE 'E'.
  ELSE.
    MESSAGE '...' TYPE 'E'.
  ENDIF.
ENDFORM.