凡尘clsoho™的博客

E-mail & MSN: clsoho@hotmail.com
QQ1超级群: <101817641已满> QQ2群:<110722895已满>
QQ3超级群:<23765855>QQ4超级群:<85338969>

DESCRIBE FIELD

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].

Extras: 附加选项

1. ... TYPE typ [COMPONENTS com]  类型

2. ... LENGTH ilen IN { BYTE | CHARACTER } MODE
长度

3. ... DECIMALS dec
小数位数

4. ... OUTPUT-LENGTH olen
输出长度

5. ... HELP-ID hlp
帮助ID

6. ... EDIT MASK mask

Effect 作用

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.

这个语句判断数据对象dobj的一些属性并且把它们指定到指定的变量中。多样的选项使你能够判断数据类型和结构字段的数量,内存中使用的长度,显示的小数位数,输出长度,所参照数据字典中数据元素的类型名称,和一个可能的转换子例程。

Notes

  • You can specify field symbols or formal parameters in procedures for dobj to determine the properties of the data object they represent at the time of the statement execution.

你可以为dobj指定字段符号或者子程序的形式参数来判断数据对象在语句运行时所代表的属性。

  • The statement DESCRIBE is used to determine the properties of data objects of elementary data types. When DESCRIBE is used for structures or data objects of deep data types like strings, internal tables, or reference variables, you can only determine elementary properties. Further details, for example, 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). They enable you to determine all properties of data objects of all data types.

Describe语句用来判断基本数据类型的数据对象的属性。当describe判断结构或者复杂数据类型的数据对象像像字符串,内表或者引用变量,就只能判断其基本属性。更详细说,例如,静态的或者动态的引用变量DESCRIGE是判断不了它的属性的。对于这种情况,你可以使用运行时类型服务的类型类,它可以指定所有数据类型的数据对象的全部属性。

Addition 1 选项1

... TYPE typ [COMPONENTS com]

Effect 作用

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.

判断数据对象dobj的数据类型,把相应的一们标识赋给数据对象typ,它期望一个字符型的数据类型。下表列出了所有可能的数据类型的有大小写之分的返回值。

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.

选项components指定数据对象dobj的直接字段数量到数据对象com中。Com是整形值。如果数据对象不是一个结构,将返回0。如果dobj是嵌套结构,只有最高层级的组件被计算在内。

Note

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.

如果你不使用选项components,对于任何结构,选项typenon-unicode程序中返回“C”替代“U”或者“V”。

Example 例子

For the deeply nested structure struc1, the type identification "v" and 3 components are determined. For the flat structure struc2, the type identification "u" and 2 components are determined.

对于深层嵌套结构struc1,类型标识为“v”并且有3个组件。对于扁平结构struc2,类型标识为”u”并且有两个组件。

DATA: BEGIN OF struc1,
        comp1 TYPE c,
        comp2 TYPE string,
        BEGIN OF struc2,
          comp1 TYPE c,
          comp2 TYPE i,
        END OF struc2,
      END OF struc1,
      typ1(1) TYPE c,
      comp1   TYPE i,
      typ2(1) TYPE c,
      comp2   TYPE i.

DESCRIBE FIELD: struc1        TYPE typ1 COMPONENTS comp1,
                struc1-struc2 TYPE typ2 COMPONENTS comp2.

测试运行结果:typ1: v comp1:3 typ2: u comp2:2

Addition 2 选项2

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

Effect 作用

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.

数据对象dobj在内存中直接使用的长度被以字节或者字符为单位(取决于选项mode)判断出来并指定给数据对象ilenilen的数据类型为i.

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.

unicode程序中你必须指定选项mode.具有选项IN BYPE MODE的变式以字节为单位来判断数据对象的长度.具有IN CHARACTER MODE选项的变式以字符为单位来判断数据对象dobj 的长度.当使用in character mode 进,dobj的数据类型必须是扁平的和字符型的。你只能为复杂数据类型指定in byte mode,并且在这种情况下,引用的长度是确定的(8字节)。

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

non-Unicode程序和6.10之前的版本中,可以不使用选项mode来使用length.在这种情况下,选项in byte mode是在隐式使用的。

Note

For data objects with a fixed length, the length is determined that is specified during the creation of the data object. To determine the the used length of character-type data objects without counting the trailing spaces, you can use the built-in function strlen.

对于具有固定长度的数据对象,长度是在对象创建时就被被确定的。为了判断字符型数据对象的长度而不计算后面的空格 ,可以使用内建函数strlen

Example 例子

Calculation of bytes required for the display of one character. The result is greater than 1 in multi-byte systems. .

计算显示一个字符所需要的字节数。在多字节系统中结果大于1.

DATA: text(1) TYPE c,
      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.

测试运行结果:bytes :2说明一个字符需要两个字节。

Addition 3 选项3

... DECIMALS dec

Effect 作用

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

判断数据对象dobj的小数位数并且把它指定到数据对象dec中。Dec的数据类型为i.

Note

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.

只有数据类型为P的数据对象有小数位数。所以,只有对于这些数据对象dec中的结果才会不为0.

Addition 4 选项

... OUTPUT-LENGTH olen

Effect 作用

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.

对于定长的数据对象,判断屏幕布局所要求的输出长度并且把它指定到数据对象olen。结果与数据对象参照它的数据类型所预定义的输出长度是相对应的。对于字符串,olen总是设置为值0.oleni类型。

Notes

  • Normally, the required output length is specified by the entry in the table for predefined output formats. 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.

通常,要求的输出长度是由预定义的输出格式决定的。这并不是这种情况,当数据对象的数据类型是参照abap字典定义的并且输出长度或者一个转换例程在相应的域中被指定。

  • When the output length defined in a screen of a screen field with the identical name of dobj is shorter than the required output length, an exception that cannot be handled is triggered in case of an overflow. During the transfer to the list buffer, the outputs are truncated if the output length is shorter than the required output length.

当屏幕是和dobj具有相同名称的屏幕字段定义的输出长度比要求的输出长度短时,将会触发一个不可处理的溢出异常。在传送到列表缓冲区期间,如果输出长度比要求输出的长度短,输出值将被缩短。

  • When separators or templates are provided in the user master record for the output of a data type, they are only displayed if the defined output length is sufficient. The required length can be longer than the output length determined by OUTPUT-LENGTH.

当分隔符或者模板在用户主数据中被提供,为数据类型的输出,他们只有在定义的输出长度足够长的时候才被显示。要求的输出长度可以比用outpu-length定义的输出长度长。

  • The output length for strings can be determined using the functions strlen or xstrlen.

字符串的输出长度可以用函数strlen或者xstrlen来决定。

Example 例子

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.

对于date1,输出长度为8,是由相应的类型d决定的。对于date2,输出长度10是由域SYDATS决定的。

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 选项5

... HELP-ID hlp

Effect 作用

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.

如果数据对象dobj的数据类型是由abap字典的数据元素决定的,数据类型的名称就被指定给字段hlp,它是当定义数据对象dobj时用在type后面的元素的名称。如果数据对象没有参照abap字典的数据对象,hlp是初始值。对于hlp,类型为字段型的数据对象,如果是6.10之前的版本的话,它须发是c数据类型的。

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. As of release 6.10, the complete name of the structure component is returned.

6.10版本之前,当为dobj指定字段符号时会返回相关的数据元素的名称,一个数据对象被指定给这个字段符号使用语句assign component,并且数据对象参照abap字典的结构的一个字段。在版本6.10中,将会返回结构字段的完整名称。

Note

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.

这个选项之所以称作help-id是因为在hlp中的数据类型的名称可以被用来显示字段在abap字典中定义的输入输出帮助。

Example 例子

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.

describe field之后,hlp包含值”SPFLI-CARRID”.一个在abap字典中定义的输入帮助被指定给这个字段,输入帮助可以被显示用函数模块F4IF_FIELD_VALUE_REQUEST.如果名称s_carr_idtype后被指定当定义carrid时,hlp包含值”S_CARR_ID”并且被使用。例如,来显示字段帮助通过使用函数模块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.

Addition 6 选项6

... EDIT MASK mask

Effect 作用

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.

如果一个转换子例程被指定给数据对象dobj对过参照abap字典的域,两个等号标志“==”在转换子例程的名称之前并且结果被指定给数据对象mask,如果没有为数据对象指定转换子例程,mask为初始值。Mask为字符型的数据对象。

Note

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.

如果一个数据对象mask遇到这些要求,你可以使用它通过write语句的选项using edit mask来调用转换子例程。

Example 例子

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.

如果在abap字典中的数据元素s_fltime被与取决于域s_dura的转换子例程sdura关联起来,在describe field之后msk包含值”==SDURA”并且在从秒轮换成分之后语句write返回值“533”。

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.

posted on 2010-03-09 13:42  凡尘clsoho  阅读(1228)  评论(0编辑  收藏  举报