ABAP Keyword Documentation → ABAP - Reference → Processing Internal Data → Attributes of Data Objects → DESCRIBE
DESCRIBE TABLE
Other versions: 7.31 | 7.40 | 7.54
Syntax
DESCRIBE TABLE itab [KIND knd] [LINES lin] [OCCURS n].
Extras
2. ... LINES lin
3. ... OCCURS n
Effect
This statement determines some of the properties of the internal table itab
and assigns them to the specified target fields. The following can be specified as target fields of each addition:
- Existing variables to which the return value can be converted.
-
Inline declarations
DATA(var)
.
The various additions enable the table category, the number of currently filled rows, and the initial memory requirement to be determined.
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
-
For more detailed information about an internal table, it is best to use the methods of the
RTTS of the statement
DESCRIBE TABLE
. -
If no addition is specified, the statement
DESCRIBE TABLE
only sets the system fieldssy-tfill
andsy-tleng
.
Addition 1
... KIND knd
Effect
Determines the table category of the internal table itab
. The return value
is a single character character-like ID. In an inline declaration, a variable of the tye c
with length 1 is declared.
The possible IDs 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
Determines the current number of table rows in the internal table itab
. The
return value has the type i
. In an inline declaration, a variable of the tye ci
is declared.
Note
The current number of rows of an internal table can also be determined using the
predefined
function lines
, which can be used in suitable
operand positions.
Addition 3
... OCCURS n
Effect
Determines the initial memory requirements defined using the addition
INITIAL SIZE or the obsolete addition OCCURS
when the internal table is created. The return value has the type i
. In an inline declaration, a variable of the tye ci
is declared.
Example
Sorts a generically typed internal table in a subroutine in descending order. Since sorted tables cannot be sorted in descending order, the table category is checked to prevent non-handleable exceptions from being raised.
FORM sort_descending CHANGING itab TYPE ANY TABLE.
DESCRIBE TABLE itab KIND DATA(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.