DESCRIBE - Supply attributes of a field


Basic form

DESCRIBE FIELD f.

Effect

Supplies the attributes of the field f . You must specify at least one of the additions:

Additions



1. ... LENGTH len
2. ... TYPE typ
3. ... TYPE typ COMPONENTS n
4. ... OUTPUT-LENGTH len
5. ... DECIMALS n
6. ... EDIT MASK mask

Addition 1

... LENGTH len

Effect

Returns the length of the field f in the field
len .

Example

DATA: FLD(8), LEN TYPE P. DESCRIBE FIELD FLD LENGTH LEN.
Result: LEN contains the value 8.

Addition 2

... TYPE typ

Effect

Returns the data type of f in the field typ

Example

DATA: FLD(8) TYPE N, F_TYPE. DESCRIBE FIELD FLD TYPE F_TYPE. Result: F_TYPE contains the value 'N' .

Note

Along with the elementary data types you can specify under DATA (C, N, etc.), several other data types are created either with reference to Dictionary fields or during generation. These data types, which are also returned by DESCRIBE , have the following type IDs:

h Internal table s 2-byte integer with leading sign b 1-byte integer without leading sign u Structure without internal table v Structure containing at least one internal table
For compatibility reasons, ... TYPE typ returns C rather than u or v with structures.

Addition 3

... TYPE typ COMPONENTS n

Effect

Similar to ... TYPE typ except that, with structures in typ , u or v are returned and in the number of structure components is set in n . If f is not a structure, n is set to 0.

Example

Recursive processing of the pages of an ABAP/4 data structure:
FORM TEST USING F. DATA: TYP(1) TYPE C, N TYPE I. FIELD-SYMBOLS: <F>. DO. ASSIGN COMPONENT SY-INDEX OF STRUCTURE F TO <F>. IF SY-SUBRC <> 0. EXIT. ENDIF. DESCRIBE FIELD <F> TYPE TYP COMPONENTS N. IF N > 0. " Equivalent is TYP = 'u' OR TYP = 'v' PERFORM TEST USING <F>. ELSE. PERFORM DO_SOMETHING USING <F>. ENDIF. ENDDO. ENDFORM.

Addition 4

... OUTPUT-LENGTH len

Effect

Enters the output length of the field f in the variable len .

Example

DATA: FLD(4) TYPE P, O_LEN TYPE P. DESCRIBE FIELD FLD OUTPUT-LENGTH O_LEN.
Result: O_LEN contains the value 8.

Addition 5

... DECIMALS n

Effect

Enters the number of decimal places for the field f (defined in addition ... DECIMALS of the DATA statement or in the ABAP/4 Dictionary ) in the variable n .

Example

DATA: FLD(8) TYPE P DECIMALS 2, DEC TYPE P. DESCRIBE FIELD FLD DECIMALS DEC.

Resultat: DEC contains the value 2.

Addition 6

... EDIT MASK mask

Effect

If the field f has a conversion routine in the ABAP/4 Dictionary , this is placed in the field mask in the form " ==conv ". " conv " stands for the name of the conversion routine, e.g. " ==ALPHA " in the conversion routine " ALPHA ". In this form, mask can then be used in the addition USING EDIT MASK mask of the WRITE statement.

Example

Check whether there is a conversion routine for the field "customer number" in the table SBOOK :
TABLES SBOOK. DATA: CONV_EXIT(10). DESCRIBE FIELD SBOOK-CUSTOMID EDIT MASK CONV_EXIT. IF CONV_EXIT <> SPACE. ... ENDIF.

Result: CONV_EXIT contains the value " ==ALPHA ".

Note

If the required field is only known at runtime, this field can also be assigned dynamically to a field symbol (see FIELD-SYMBOLS , ASSIGN ).

Index
© SAP AG 1996