DESCRIBE TABLE

本文详细介绍了ABAP中的DESCRIBETABLE语句的使用方法及功能,包括如何通过该语句获取内表的类型、当前行数及初始内存需求等信息,并提供了实际应用的例子。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

DESCRIBE TABLE

Syntax 语法

DESCRIBE TABLE itab [KIND knd] [LINES lin] [OCCURS n].

Extras: 选项

1. ... KIND knd

2. ... LINES lin

3. ... OCCURS n

Effect 作用

This statement determines some properties of the internal table itab and assigns them to the specified variables. The various additions enable you to determine the table type, the number of currently filled rows and the initial memory requirement.

这个语句判断内表itab的某些属性并把它们指定到指定的变量中。不同的选项使你能够判断表类型,当前字段行数和初始化需要的内存大小

In addition, the system fields sy-tfill and sy-tleng are filled with the current number of table rows and the length of a table row in bytes.

另外,系统字段sy-tfillsy-tleng保存着当前表行数量和以字节计的表行长度。

Notes

  • For detailed information about an internal table, you should use the methods of RTTS instead of the statement DESCRIBE TABLE.

为了更详细的关于内表的信息,你应该用RTTS的方法代替语句describe table.

  • Without the specification of an addition, the statement DESCRIBE TABLE only sets the system fields sy-tfill and sy-tleng.
    没有指定一个附加项,语句describe table只设置系统字段sy-tfill sy-tleng的值。

Addition 1 选项1

... KIND knd

Effect 作用

The table type of the internal table itab is determined and a corresponding one-digit identification is assigned to the data object knd. A character-type data type is expected for the data object. The identifications are "T" for standard tables, "S" for sorted tables and "H" for hashed tables. These values are also defined as constants sydes_kind-standard, sydes_kind-sorted, and sydes_kind-hashed in the type group SYDES.

判断内表itab的表类型并且把一个相应的一字符的标识赋给字符型的数据类型的数据对象knd. 标识为T时代表是标准表,为S时为排序表,为H是为哈唏表。这些值在类型组SYDES中也被定义成常量sydes_kind-standard,sydes_kind-sorted,sydes_kind-hashed

Addition 2 选项2

... LINES lin

Effect 作用

The current number of table rows of the internal table itab is determined and is assigned to the data object lin.The data type i is expected for the data object.

决定内表表行的当前数量并且把值赋给数据对象linLinI类型的数据对象。

Note

As of release 6.10, the current number of rows of an internal table can also be determined using the in-built function lines.

在版本6.10中,内表表行的当前数量也可以用内建函数lines来判断。

Addition 3 选项3

... OCCURS n

Effect 作用

The initial memory requirement defined during the creation of the internal table with the addition INITIAL SIZE or the obsolete addition OCCURS is determined and assigned to the data object n. The data type i is expected for the data object.

在内表用选项initial size或者老式的选项ocurs创建期间决定内表所需的初始化内存大小并且把值赋给数据对象n.Ni类型的数据对象。

Example 例子

Descending sorting of a generically typed internal table in a subprogram. Since sorted tables cannot be sorted in a descending order, the table type is checked to avoid an exception that cannot be handled.

在一个子程序中对一个一般内表进行递减排序。因为排序表不能降序排列,所以会进行表类型检查来避免不能处理的异常。

TYPE-POOLS sydes.
...
FORM sort_descending CHANGING itab TYPE ANY TABLE.
  DATA tabkind(1) TYPE c.
  DESCRIBE TABLE itab KIND tabkind.
  IF tabkind = sydes_kind-standard OR
     tabkind = sydes_kind-hashed.
    SORT itab DESCENDING.
  ELSEIF tabkind = sydes_kind-sorted.
    MESSAGE '...' TYPE 'E'.
  ELSE.
    MESSAGE '...' TYPE 'E'.
  ENDIF.
ENDFORM.

转载于:https://www.cnblogs.com/clsoho/archive/2010/03/10/1682175.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值