SAP DESCRIBE TABLE ABAP Statements



Get Example source ABAP code based on a different SAP table
  


• DESCRIBE TABLE ABAP Statement

DESCRIBE TABLE
Short Reference

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

ABAP Addition
1 ... KIND knd
2 ... LINES lin
3 ... OCCURS n

What does it do?
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) or FINAL(var).
The different additions enable the table category, the number of currently filled lines, 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 lines and the length of a table line in bytes.



Latest notes:

For more detailed information about an internal table, it is best to use the methods of the RTTS instead of the statement DESCRIBE TABLE.
If no addition is specified, the statement DESCRIBE TABLE only sets the system fields sy-tfill and sy-tleng.
ABAP_HINT_END
• KIND DESCRIBE TABLE

ABAP Addition

What does it do?
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 pool SYDES.



Example ABAP Coding

Sorting of 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 uncatchable exceptions from being raised.
ABEXA 00229
ABAP_EXAMPLE_END
• LINES DESCRIBE TABLE

ABAP Addition

What does it do?
Determines the current number of table lines in the internal table itab. The return value has the type i. In an inline declaration, a variable of the type i is declared.



Latest notes:

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



Example ABAP Coding

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

ABAP Addition

What does it do?
Determines the initial memory requirement defined using the addition INITIAL SIZE or the obsolete addition OCCURS when the internal table is created.
If neither INITIAL SIZE nor OCCURS were used:
For internal tables created by RANGES or INFOTYPES, the standard value 10 is returned.
In all other cases, the initial memory requirement is fully set by the ABAP runtime framework and the value of n is set to 0.
The return value has the type i. In an inline declaration, a variable of the type i is declared.



Latest notes:

The value 0 for an initial memory requirement fully set by the ABAP runtime framework reflects the value 0 that can be specified behind INITIAL SIZE or OCCURS to define this behavior.
ABAP_HINT_END



Example ABAP Coding

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

Return to menu