DESCRIBE FIELD dobj
[TYPE typ [COMPONENTS com]]
[LENGTH ilen IN {BYTE|CHARACTER} MODE]
[DECIMALS dec]
[OUTPUT-LENGTH olen]
[HELP-ID hlp]
[EDIT MASK mask].
1. ... TYPE typ [COMPONENTS com]
2. ... LENGTH ilen IN {BYTE|CHARACTER} MODE
3. ... DECIMALS dec
4. ... OUTPUT-LENGTH olen
5. ... HELP-ID hlp
6. ... EDIT MASK mask
This statement determines several properties of the data object dobj and assigns them to the specified variables. The various additions enable you to determine the data type and the number of components for structures, the length used in the memory, the number of decimal places, the output length, the name of the data type for a reference to a data element of the ABAP Dictionary, and a possible conversion routine.
... TYPE typ [COMPONENTS com]
The data type of the data object dobj is determined and
a corresponding one-digit identification is assigned to the data object
typ, which expects a character-type data type. The following table lists the assignment of return values for all possible data types. The identification is case-sensitive.
Identification | Data Type |
b | Elementary type b |
C | Elementary type c (exception, see note below) |
D | Elementary type d |
F | Elementary type f |
g | Elementary type string |
h | Internal table |
i | Elementary type i |
l | Data reference |
N | Elementary type n |
P | Elementary type p |
r | Object reference |
s | Elementary type s |
T | Elementary type t |
u | flat structure (exception, see note below) |
v | deep structure (exception, see note below) |
X | Elementary type x |
y | Elementary type xstring |
The addition COMPONENTS assigns the number of direct components
of the data object dobj to the data object
com. The data type i is expected for
com. If the data object dobj is not a structure,
the value 0 is returned. If dobj is a nested structure, only the components of the highest hierarchy level are counted.
If you do not use the addition COMPONENTS, the addition TYPE in
non-unicode programs returns the value "C" instead of "u" or "v" for any structures.
For the deeply nested structure struc1, the type identification "v" and three components are determined. For the flat structure struc2, the type identification "u" and two components are determined.
DATA: BEGIN OF struc1,
comp1 TYPE c LENGTH 1,
comp2 TYPE string,
BEGIN OF struc2,
comp1 TYPE c LENGTH 1,
comp2 TYPE i,
END OF struc2,
END OF struc1,
typ1 TYPE c LENGTH 1,
comp1 TYPE i,
typ2 TYPE c LENGTH 1,
comp2 TYPE i.
DESCRIBE FIELD: struc1 TYPE typ1 COMPONENTS comp1,
struc1-struc2 TYPE typ2 COMPONENTS comp2.
... LENGTH ilen IN {BYTE|CHARACTER} MODE
The length directly used by the data object dobj in the memory is determined in bytes or characters depending on the addition MODE and is assigned to the data object ilen. The data type i is expected for ilen.
You must specify the addition MODE in Unicode programs. The variant with the addition IN BYTE MODE determines the length of the data object dobj in bytes. The variant with the addition IN CHARACTER MODE determines the length of the data object dobj in characters. When using IN CHARACTER MODE, the data type of dobj must be flat and character-type. You can only specify IN BYTE MODE for deep data types and in this case, the length of the reference (8 bytes) is determined.
In non-Unicode programs and in
releases prior to 6.10, LENGTH can be used without the
addition MODE. In this case, the addition IN BYTE MODE is used implicitly
For data objects with a fixed length, the length is determined that is specified during the creation of the data object. To determine the used length of character-type data objects without counting the trailing spaces, you can use the
built-in function strlen.
Calculation of bytes required for the display of one character. The result is greater than 1 in multi-byte systems. .
DATA: text TYPE c LENGTH 1,
blen TYPE i,
clen TYPE i,
bytes TYPE i.
DESCRIBE FIELD text: LENGTH blen IN BYTE MODE,
LENGTH clen IN CHARACTER MODE.
bytes = blen / clen.
... DECIMALS dec
The number of decimalplaces of
the data object dobj is determined and assigned to the
data object dec. The data type i is expected for dec.
Only data objects of the data type p can have decimal
places. Therefore, the result in dec can be different from 0 for these data objects only.
... OUTPUT-LENGTH olen
For data objects with a fixed length, the output length required for
screen layouts is determined and assigned
to the data object olen. The result corresponds to the
predefined output length of the data object according to its data type during the output in the list
buffer. For strings, olen is always set to the value 0.
The data type i is expected for olen.
For date1, the output length 8 which corresponds to the type d is determined. For date2, the output length 10 which is defined in the domain SYDATS is determined.
DATA: date1 TYPE d,
date2 TYPE sy-datum,
olen1 TYPE i,
olen2 TYPE i.
DESCRIBE FIELD: date1 OUTPUT-LENGTH olen1,
date2 OUTPUT-LENGTH olen2.
... HELP-ID hlp
If the data type of the data object dobj is determined by a data element of the ABAP Dictionary, the name of the data type is assigned to the field hlp. It is the name that was used after the addition TYPE when defining the data object dobj. If the data object does not refer to a data object of the ABAP Dictionary, hlp is initialized. For hlp, a character-type data object is expected that had be of the data type c if a release prior to 6.10 was used.
Prior to release 6.10, the name of the corresponding data element was returned when a field symbol is
specified for dobj, a data object is assigned to this
field symbol using the statement ASSIGN COMPONENT, and
the data object refers to a component of a structure in the ABAP Dictionary. Since release 6.10, the complete name of the structure component is returned.
The addition is called HELP-ID because the name of the
data type in hlp can be used for the display of the field help or input help assigned in the ABAP Dictionary.
After DESCRIBE FIELD, hlp contains the value "SPFLI-CARRID". Since an input help is assigned to this component in the ABAP Dictionary, the input help can be displayed using the function module F4IF_FIELD_VALUE_REQUEST. If the name s_carr_id is specified after TYPE when defining carrid, hlp contains the value "S_CARR_ID" and can be used, for example, to display the field help using the function module HELP_OBJECT_SHOW.
DATA: carrid TYPE spfli-carrid,
hlp TYPE string,
struc TYPE dfies-tabname,
comp TYPE dfies-fieldname.
DESCRIBE FIELD carrid HELP-ID hlp.
SPLIT hlp AT '-' INTO struc comp.
CALL FUNCTION 'F4IF_FIELD_VALUE_REQUEST'
EXPORTING
tabname = struc
fieldname = comp
EXCEPTIONS
field_not_found = 1
no_help_for_field = 2
inconsistent_help = 3
no_values_found = 4
OTHERS = 5.
... EDIT MASK mask
If a conversion routine is assigned to the data object dobj
by refering to a domain in the ABAP Dictionary, two equals signs "==" precede the name of the conversion
routine and the result is assigned to the data object mask.
If no conversion routine is assigned to the data object, mask
is initialized. A character-type data object is expected for mask.
If a data object mask meets these requirements, you can
use it in the addition USING EDIT MASK of the statement WRITE to call the conversion routine.
Since the data element S_FLTIME in the ABAP Dictionary is associated with the conversion routine SDURA due to the domain S_DURA, msk contains the value "==SDURA" after DESCRIBE FIELD and the statement WRITE returns the value "5:33" after the conversion from seconds into minutes.
DATA: time TYPE s_fltime,
seconds TYPE i,
msk TYPE string.
DESCRIBE FIELD time EDIT MASK msk.
seconds = 333.
WRITE seconds USING EDIT MASK msk.