Skip to content

ABAP Keyword Documentation →  ABAP − Reference →  Processing Internal Data →  Attributes of Data Objects →  DESCRIBE 

DESCRIBE TABLE

Quick Reference

Other versions: 7.31 | 7.40 | 7.54

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:

  • 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 fields sy-tfill and sy-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 type 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.


Example

Sorts a generically typed internal table in a method 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.

CLASS demo DEFINITION. 
  PUBLIC SECTION. 
    CLASS-METHODS sort_descending CHANGING itab TYPE ANY TABLE. 
ENDCLASS. 

CLASS demo IMPLEMENTATION. 
  METHOD sort_descending. 
    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. 
  ENDMETHOD. 
ENDCLASS. 

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 type i is declared.


Note

The current number of rows of an internal table can also be determined using the built-in function lines, which can be used in suitable operand positions.


Example

The example shows that the addition of LINES to DESCRIBE TABLE and the built-in function lines have the same result.

SELECT carrid 
       FROM scarr 
       INTO TABLE @DATA(scarr_tab). 

DESCRIBE TABLE scarr_tab LINES DATA(lines). 

ASSERT lines = lines( scarr_tab ). 

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 type i is declared.


Example

The example shows that the addition of OCCURS to DESCRIBE TABLE and the attribute INITIAL_SIZE of a type description object of class CL_ABAP_TABLEDESCR produce the same value.

DATA itab TYPE TABLE OF i INITIAL SIZE 10 WITH EMPTY KEY. 

DESCRIBE TABLE itab OCCURS DATA(occ). 

ASSERT occ = CAST cl_abap_tabledescr( 
  cl_abap_typedescr=>describe_by_data( itab ) )->initial_size.