DESCRIBE - Return attributes of an internal table

Basic form

DESCRIBE TABLE itab.

Effect

Returns the attributes of the internal table itab. You must use at least one of the additions listed below:

Note

The DESCRIBE statement cannot be used for all ABAP types. In connection with ABAP Objects, SAP has introduced a RTTI concept based on system classes to determine type attributes at runtime. This concept applies to all ABAP types and as such covers all the functions of the DESCRIBE TABLE statement.

Extras:


1. ... LINES n

2. ... OCCURS n

3. ... KIND   k

Addition 1

... LINES n

Effect

Places the number of filled lines of the table t in the field lin. The value returned to lin has type I.

Note

The number of filled lines of the table itab can also be ascertained using the predefined function lines( itab ).

Example

DATA: N    TYPE I,

      ITAB TYPE TABLE OF I.
...
CLEAR ITAB.
APPEND 36 TO ITAB.
DESCRIBE TABLE ITAB LINES N.

Result: N contains the value 1.

Addition 2

... OCCURS n

Effect

Passes the size of the OCCURS parameter from the table definition (as defined with DATA) to the variable n. The value returned to n has type I.

Example

DATA: N1    TYPE I,
      N2    TYPE I,
      ITAB1 TYPE TABLE OF I INITIAL SIZE 10,
      ITAB2 TYPE I OCCURS 5.
DESCRIBE TABLE ITAB1 OCCURS N1.
DESCRIBE TABLE ITAB2 OCCURS N2.

Result: OCC contains the value 10 and N2 the value 5.

Addition 3

... KIND k

Effect

Writes the table type from itab to the variables n. The value returned to k is of type C. The constants SYDES_KIND-STANDARD, SYDES_KIND-SORTED and SYDES_KIND-HASHED are defined in the type group SYDES for the return values.

Example

Generic FORM routine any table type

TYPE-POOLS: SYDES.
...
FORM GENERIC_FORM USING ITAB TYPE ANY TABLE.
  DATA: K TYPE C.
  DESCRIBE TABLE ITAB KIND K.
  CASE K.
    WHEN SYDES_KIND-STANDARD.
      ...
    WHEN SYDES_KIND-SORTED.
      ...
    WHEN SYDES_KIND-HASHED.
      ...
  ENDCASE.
ENDFORM.

Notes

  1. Performance: The runtime for executing the DESCRIBE TABLE statement is approximately 4 msn (standardized microseconds).
  2. The DESCRIBE TABLE statement also passes values to the SY-TFILL and SY-TLENG System fields

Additional help

Determining the Attributesof Internal Tables