sapdev logo background
sapdev logo sapdev logo
Comments

ABAP DESCRIBE FIELD INTO Statement syntax, information and example SAP source code



Return to Statement index



DESCRIBE FIELD INTO


ABAP Syntax DESCRIBE FIELD dobj INTO td.

What does it do? All characteristics of the f field, its components, subcomponents, and so on, are displayed in the td field ( type description ). td must be of type SYDES_DESC
, which is defined in type group SYDES .
The SYDES_DESC structure has two table-like components,
TYPES and NAMES :

In TYPES , the tree structure of the type belonging to f is mapped. The components of a node are stored close together in table TYPES . The beginning and end of the line area that represents the components are stored in TYPES-FROM and
TYPES-TO . The reference to the higher-level node can be found in
TYPES-BACK . If there is no higher-level or subordinate node, this is indicated by the value 0 (for the meaning of further components, see the following sections).

The names of components, types, and so on are not stored in
TYPES directly. Instead, the components TYPES-IDX_... each have an index in name table NAMES . The value 0 indicates that there is no reference to the name table.

In component NAMES-NAME , NAMES contains the (possibly fragmented) names. If a name continues in the following line, this is indicated by an asterisk ('*') in the component NAMES-CONTINUE .

The type description table ( TYPES ) not only stores information about the tree structure but also further information about the type of f and its components. This particularly includes all information that can be determined using the usual additions to DESCRIBE FIELD
. TYPES contains the following columns:

IDX_NAME Component name

IDX_USER_TYPE Name of a user-defined type, that is, a type that was defined by a TYPES statement. Derived types (<(>... TYPE A-B<)>) and structures from the ABAP Dictionary are not considered to be user-defined types.

CONTEXT For user-defined types only: The context in which the type is defined. Possible values are defined in the
SYDES_CONTEXT constants of type group
SYDES . Use these constants for comparison purposes only. A distinction is made between the following type contexts:

SYDES_CONTEXT-PROGRAM : Program-global type
SYDES_CONTEXT-FORM : Local FORM type
SYDES_CONTEXT-FUNCTION : Local FUNCTION type
SYDES_CONTEXT-METHOD : Local METHOD type

IDX_CONTEXT_NAME For user-defined types only:
With a local context: The name of the FORM or FUNCTION in which the type was defined. The name of the associated program is then the first entry in the name table.
With a global context: The name of the program in which the type was defined.

IDX_EDIT_MASK Conversion routine from the ABAP Dictionary, corresponds to the EDIT MASK addition with a simple DESCRIBE


IDX_HELP_ID Help ID when referencing fields from the ABAP Dictionary

LENGTH Internal length, corresponds to the LENGTH
addition with a simple DESCRIBE

OUTPUT_LENGTH Output length, corresponds to the
OUTPUT-LENGTH addition with a simple DESCRIBE

DECIMALS Number of decimal digits
, corresponds to the DECIMALS addition with a simple
DESCRIBE

TYPE ABAP type, corresponds to the TYPE addition with a simple DESCRIBE . If DESCRIBE INTO is applied to a nested structure that contains a boxed component , the type is returned with the internal ID j (
static box ).
TABLE_KIND A table type is stored here for the components that represent an internal table. The same values are returned as for the variant DESCRIBE TABLE itab KIND k . Components that do not represent a table receive the return value SYDES_KIND-UNDEFINED (see type group SYDES ).

Example ABAP Coding Definition of the complex data type <(>EMPLOYEE_STRUC
<)>:

PROGRAM DESCTEST.



TYPES: BEGIN OF name_struc,
first TYPE c LENGTH 20,
last TYPE c LENGTH 20,
END OF name_struc,

BEGIN OF absence_time_struc,
day TYPE d,
from TYPE t,
to TYPE t,
END OF absence_time_struc,

phone_number TYPE n LENGTH 20,

BEGIN OF employee_struc,
id LIKE sbook-customid,
name TYPE name_struc,
BEGIN OF address,
street TYPE c LENGTH 30,
zipcode TYPE n LENGTH 4,
place TYPE c LENGTH 30,
END OF address,
salary_per_month TYPE p LENGTH 10 DECIMALS 3,
absent TYPE STANDARD TABLE OF absence_time_struc
WITH NON-UNIQUE DEFAULT KEY,
phone TYPE STANDARD TABLE OF phone_number
WITH NON-UNIQUE DEFAULT KEY,
END OF employee_struc.

You can determine the structure of the type by using type group SYDES as follows:

DATA: employee TYPE employee_struc,
td TYPE sydes_desc.

DESCRIBE FIELD employee INTO td.

The following table shows a few selected columns of type description table TD-TYPES . For a better overview, the names of the columns IDX_NAME , IDX_UERR_TYPE , and IDX_EDIT_MASK
have been shortened:

|FROM| TO |BACK|NAME|UTYP|EMSK|TYPE
---|----|----|----|----|----|----|----
01 | 2 | 7 | 0 | 0 | 2 | 0 | v
02 | 0 | 0 | 1 | 6 | 0 | 4 | N
03 | 8 | 9 | 1 | 7 | 5 | 0 | u
04 | 10 | 12 | 1 | 8 | 0 | 0 | u
05 | 0 | 0 | 1 | 9 | 0 | 0 | P
06 | 13 | 13 | 1 | 11 | 0 | 0 | h
07 | 17 | 17 | 1 | 12 | 0 | 0 | h
08 | 0 | 0 | 3 | 13 | 0 | 0 | C
09 | 0 | 0 | 3 | 14 | 0 | 0 | C
10 | 0 | 0 | 4 | 15 | 0 | 0 | C
11 | 0 | 0 | 4 | 16 | 0 | 0 | N
12 | 0 | 0 | 4 | 17 | 0 | 0 | C
13 | 14 | 16 | 6 | 0 | 18 | 0 | u
14 | 0 | 0 | 13 | 20 | 0 | 0 | D
15 | 0 | 0 | 13 | 21 | 0 | 0 | T
16 | 0 | 0 | 13 | 22 | 0 | 0 | T
17 | 0 | 0 | 7 | 0 | 0 | 0 | N

Note that the entries in rows 6 and 7 represent internal tables (
ABAP type h). There is always an entry for the corresponding row type (rows 13 and 17) for an internal table.

The indices in rows 5 to 7 refer to entries in name table
TD-NAMES . If you look, for example, at row 3, you find the corresponding component name in TD-NAMES from row 7 ( NAME ) onwards and the corresponding user type from row 5 ( NAME_STRUC ) onwards.

In name table TD-NAMES , you find the following entries. Note that the names <(>SALARY_PER_MONTH<)> and <(>ABSENCE_TIME_STRUC<)> are stored in two parts:

|CONTINUE|NAME |CONTINUE|NAME
---|--------|-------------- ----|--------|--------------
01 | |DESCTEST 12 | |PHONE
02 | |EMPLOYEE_STRUC 13 | |FIRST
03 | |SBOOK-CUSTOMID 14 | |LAST
04 | |==ALPHA 15 | |STREET
05 | |NAME_STRUC 16 | |ZIPCODE
06 | |ID 17 | |PLACE
07 | |NAME 18 | * |ABSENCE_TIME_ST
08 | |ADDRESS 19 | |RUC
09 | * |SALARY_PER_MONT 20 | |DAY
10 | |H 21 | |FROM
11 | |ABSENT 22 | |TO
Documentation extract taken from SAP system, � Copyright SAP AG. All rights reserved




DESCRIBE_FIELD
DESCRIBE_LIST




comments powered by Disqus