SAP NetWeaver AS ABAP Release 740, ©Copyright 2014 SAP AG. All rights reserved.
ABAP Keyword Documentation → ABAP − Reference → Processing Internal Data → Attributes of Data Objects → DESCRIBE →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 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:
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
... 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.
... 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.
... 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.