ABAPDESCRIBE_FIELD - DESCRIBE FIELD

TXBHW - Original Tax Base Amount in Local Currency   Vendor Master (General Section)  
This documentation is copyright by SAP AG.

DESCRIBE FIELD

Short Reference



Syntax

DESCRIBE FIELD dobj
  [TYPE typ [COMPONENTS com]]
  [LENGTH ilen IN {BYTE|CHARACTER} MODE]
  [DECIMALS dec]
  [OUTPUT-LENGTH olen]
  [HELP-ID hlp]
  [EDIT MASK mask].

Additions

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

Effect

This statement determines several properties of data object dobj and assigns them to the variablesspecified. 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 ofdecimalplaces, 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.

Notes

  • You can specify field symbols or formal parameters inproceduresfor dobj to determine the properties of the data object they represent at the time that the statement is executed.
  • The DESCRIBE statement is used to determine the properties of data objects of elementary data types. If DESCRIBE is used for structures or data objects ofdeepdata types such as strings, internal tables, or reference variables, you can only determine elementaryproperties. Further details such as the static or dynamic type of a reference variable cannot be determined using DESCRIBE. For this kind of information, you can use the type classes of Run Time Type Services(RTTS), which enable you to determine all properties of data objects of all data types.


Addition 1

... TYPE typ [COMPONENTS com]

Effect

The data type of data object dobj is determined and a corresponding one-digit ID is assignedto data object typ, for which a character-like data type is expected. The following table shows the assignment of return values for all possible data types. The ID is case-sensitive.

IDData Type
aElementary type decfloat16
bInternal elementary type b
CElementary type c (exception, see note below)
DElementary type d
eElementary type decfloat34
FElementary type f
gElementary type string
hInternal table
IElementary type i
lData reference
NElementary type n
PElementary type p
rObject reference
sInternal elementary type s
TElementary type t
uFlat structure (exception, see note below)
vDeep structure (exception, see note below)
XElementary type x
yElementary type xstring

The COMPONENTS addition assigns the number of direct components of data object dobj todata object com. Data type i is expected for com. If data object dobj isnot a structure, the value 0 is returned. If dobj is a nested structure, only the components of the highest hierarchy level are counted.

Notes

  • If you do not use the COMPONENTS addition, the TYPE addition innon-Unicode programs returns the value "C" instead of "u" or "v" for any structures.

  • If DESCRIBE FIELD is applied directly to astaticbox, its data type according to the above table is returned and not the internal ID j for the boxed component.


Example

For the deep nested structure struc1, the type ID "v" and three components are determined. For theflat structure struc2, the type ID "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.

Addition 2

... LENGTH ilen IN {BYTE|CHARACTER} MODE

Effect

The length used by data object dobj in the memory directly is determined in bytes or charactersdepending on the MODE addition and is assigned to data object ilen. Data type i is expected for ilen.

You must specify the MODE addition in Unicode programs. The variant with the IN BYTE MODE addition determines the length of dataobject dobj in bytes. The variant with the IN CHARACTER MODE addition determines the lengthof data object dobj in characters. When using IN CHARACTER MODE, the data type of dobj must be flat and character-like. The length ofdeepdata types can only be specified in IN BYTE MODE and the length of the reference (8 bytes) is always determined.

In non-Unicodeprograms, LENGTH can be used without the MODE addition. In this case, the IN BYTE MODE addition is used implicitly.

Note

For data objects with a fixed length, the length is determined that is specified when the data object is generated. You can use thepredefinedfunction strlen to determine the length used for character-like data objects without taking into account the closing spaces.

Example

Calculation of bytes required to display 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.

Addition 3

... DECIMALS dec

Effect

The number of decimal places for data object dobj is determined and assigned to data object dec. Data type i is expected for dec.

Note

Only data objects of data type p can have decimal places. Therefore, a result other than "0" can occur in dec for these data objects only.

Addition 4

... OUTPUT-LENGTH olen

Effect

For data objects with a fixed length, the output length required forscreenlayouts of data object dobj is determined and assigned to the data object olen. Theresult corresponds to the predefined output length that the data object has during output in the listbuffer according to its data type. For strings, olen is always set to the value 0. Data type i is expected for olen.

Notes

  • Normally, the output length required is specified by the entry in the table for predefinedoutput lengths.This is not the case when the data type of the data object is defined with a reference to the ABAP Dictionary and an output length or a conversion routine is specified in the corresponding domain.
  • If the output length defined on a screen of a dobjscreenfield with the same name is shorter than the output length required, an exception that cannot behandled is triggered when an overflow occurs. During the transfer to the list buffer, outputs are truncated if the output length is shorter than that required.
  • If separators or screens are provided in the user master record for the output of a data type, theyare only displayed if the output length defined is sufficient. The length required can be longer than the output length determined by OUTPUT-LENGTH.
  • The output length for strings can be determined using the strlen or xstrlen functions.


Example

Output length 8, associated with type d, is determined for date1. Output length 10, which is defined in the domain SYDATS, is determined for date2.

DATA: date1 TYPE d,
      date2 TYPE sy-datum,
      olen1 TYPE i,
      olen2 TYPE i.

DESCRIBE FIELD: date1 OUTPUT-LENGTH olen1,
                date2 OUTPUT-LENGTH olen2.

Addition 5

... HELP-ID hlp

Effect

If the data type of data object dobj is determined by a data element of the ABAP Dictionary,the name of the data type is assigned to the hlp field. This is the name that was used afterthe TYPE addition when data object dobj was defined. If the data object does not referto a data element of the ABAP Dictionary, hlp is initialized. A character-like data object is expected for hlp.

If a field symbol is specified for dobj to which a data object was assigned using the ASSIGNCOMPONENT statement, and this data object refers to a component of a structure in the ABAP Dictionary, the complete designation of the structure component is returned.

Note

The addition is called HELP-ID because the name of the data type in hlp can be used to display the field help or input help assigned in the ABAP Dictionary.

Example

After DESCRIBE FIELD, hlp contains the value "SPFLI-CARRID". Since an input help is assignedto this component in the ABAP Dictionary, this can be displayed using the function module F4IF_FIELD_VALUE_REQUEST.If the designation s_carr_id is specified after TYPE when carrid is defined, hlp contains the value "S_CARR_ID" and can be used, for example, to display the field help using the function moduleHELP_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.

Addition 6

... EDIT MASK mask

Effect

If a conversion routine is assigned to data object dobj by referring to a domain in the ABAPDictionary, two equals signs "==" precede the name of the conversion routine and the result is assignedto data object mask. If a conversion routine is not assigned to the data object, mask is initialized. A character-like data object is expected for mask.

Note

A mask data object populated in this way can be used directly in the USING EDIT MASK addition of the WRITE statement to call the conversion routine.

Example

Since data element S_FLTIME in the ABAP Dictionaryis linked to the conversion routine SDURA by means of the domain S_DURA, msk contains the value"==SDURA" after DESCRIBE FIELD and the WRITE statement returns the value "5:33", which has been converted from seconds to 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.


Addresses (Business Address Services)   ROGBILLS - Synchronize billing plans  
This documentation is copyright by SAP AG.


Length: 19739 Date: 20120522 Time: 050943     triton ( 459 ms )