ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 提高[FOR ALL ENTRIES]查询的效率

提高[FOR ALL ENTRIES]查询的效率

原创 Linux操作系统 作者:ultraluck 时间:2019-06-10 08:33:08 0 删除 编辑
代码实例:
DATA: it_mara TYPE STANDARD TABLE OF mara,
wa_mara TYPE mara,
it_makt TYPE STANDARD TABLE OF makt,
wa_makt TYPE makt,
it_temp_mara TYPE STANDARD TABLE OF mara,
wa_temp_mara TYPE mara.
* Get all the records from MARA
SELECT *
FROM mara
INTO TABLE it_temp_mara.
IF sy-subrc = 0.
IF NOT it_temp_mara[] IS INITIAL.
* 具有重复数据的内表
DO 100 TIMES.
APPEND LINES OF it_temp_mara TO it_mara.
ENDDO.
IF NOT it_mara[] IS INITIAL.
* Select MAKT
PERFORM select_makt.
* 排过序的内表
SORT it_mara BY matnr.
PERFORM select_makt.
* 删除了重复数据的内表
DELETE ADJACENT DUPLICATES FROM it_mara COMPARING matnr.
PERFORM select_makt.
ENDIF.
ENDIF.
ENDIF.
*&---------------------------------------------------------------------*
*& Form select_makt
*&---------------------------------------------------------------------*
* Select data friom MAKT
*----------------------------------------------------------------------*
FORM select_makt .
DATA: t1 TYPE i,
t2 TYPE i,
tmin TYPE i.
REFRESH it_makt[].
GET RUN TIME FIELD t1.
SELECT *
FROM makt
INTO TABLE it_makt
FOR ALL ENTRIES IN it_mara
WHERE matnr = it_mara-matnr.
GET RUN TIME FIELD t2.
tmin = t2 - t1.
tmin = tmin .
WRITE:/ ' Time(ms) = ', tmin.
ENDFORM.
*----------------------------------------------------------------------*

2007/03/22 Program ZTEST00100 1

Time(ms) = 1,087,713 "具有重复数据的内表
Time(ms) = 1,077,911 "排过序的内表
Time(ms) = 11,610 "删除了重复数据的内表

由上边的执行时间分析,可以得出以下结论:

·使用FOR ALL ENTRIES 时内表中不要有重复的数据

·对内表进行排序


来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/190059/viewspace-476554/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2004-12-03

  • 博文量
    167
  • 访问量
    124755