`

FOR ALL ENTRIES IN 影响速度

阅读更多

  财务一直抱怨与客户发票对帐的报表慢,公司流程是根据出货开发票,所以在此报表中有取销售订单相关信息,所以有交货与销售订单关联取数据,开始是这样处理的

*get sales order info
SELECT
A~VBELN "销售订单号
A~POSNR "销售行项目
A~KBMENG "数量
B~KNUMV "条件码
B~FAKSK "冻结码
B~AUART "订单类型
B~ERDAT "订单日期
A~NETPR "净价
A~WAERK   "工厂
A~KPEIN "销售单位
C~VBELN AS SONUM "交货单
C~POSNN "交货行项目
D~BEZEI "交货单类型
E~BSTKD "客户定单号
INTO CORRESPONDING FIELDS OF TABLE I_SD
FROM VBAK AS B INNER JOIN VBAP AS A
ON B~VBELN = A~VBELN
INNER JOIN VBFA AS C
ON A~VBELN = C~VBELV AND A~POSNR = C~POSNV
INNER JOIN TVAKT AS D
ON B~AUART = D~AUART
INNER JOIN VBKD AS E
ON E~VBELN = A~VBELN
FOR ALL ENTRIES IN I_DH
WHERE C~VBELN = I_DH-VBELN AND C~POSNN = I_DH-POSNR and
( C~VBTYP_N = 'J' OR C~VBTYP_N = 'H' OR C~VBTYP_N = 'T' ).

后来用ST05跟踪发现这个语句居然要用四分钟,其实一共也才20000条交货记录,后来到到SQL语句里面一看,原来这一句被系统分成了一万多条,而且每一条都执行成红色时间,晕倒之余,我用另一种方法让它不分解,先读出所有记录,然后再删除

SELECT
A~VBELN "销售订单号
A~POSNR "销售行项目
A~KBMENG "数量
B~KNUMV "条件码
B~FAKSK "冻结码
B~AUART "订单类型
B~ERDAT "订单日期
A~NETPR "净价
A~WAERK   "工厂
A~KPEIN "销售单位
C~VBELN AS SONUM "交货单
C~POSNN "交货行项目
D~BEZEI "交货单类型
E~BSTKD "客户定单号
INTO CORRESPONDING FIELDS OF TABLE I_SD
FROM VBAK AS B INNER JOIN VBAP AS A
ON B~VBELN = A~VBELN
INNER JOIN VBFA AS C
ON A~VBELN = C~VBELV AND A~POSNR = C~POSNV
INNER JOIN TVAKT AS D
ON B~AUART = D~AUART
INNER JOIN VBKD AS E
ON E~VBELN = A~VBELN
WHERE C~VBTYP_N = 'J' OR C~VBTYP_N = 'H' OR C~VBTYP_N = 'T' .
LOOP AT I_SD.
READ TABLE I_DH WITH KEY VBELN = I_SD-SONUM
POSNR = I_SD-POSNN.
IF SY-SUBRC <> 0.
_delete I_SD.
ENDIF.
ENDLOOP.

最后只用了十秒!

总结:数据量大的时候用FOR ALL ENTRIES IN效率会比较低,因为系统里面的处理就像两个select语句循环,其原理等同于where字句后用or条件,会占用大量内存,不如一次选出,然后用delete筛选。

分享到:
评论

相关推荐

    ABAP for all entries使用中注意的问题

    ABAP for all entries使用中注意的问题

    用FOR ALL ENTRIES IN 语句搜索 与用 IN语句搜索数据库效率对比.docx

    用FOR ALL ENTRIES IN 语句搜索 与用 IN语句搜索数据库效率对比

    Mask 98 for PRwin98

    - In Windows 3.1, set up a program item for Mask for Windows - PRWin98 in the StartUp group in Program Manager. When loaded, Mask redraws the desktop and all currently loaded, or selected, Windows...

    ABAP 开发技巧

    ABAP-FOR ALL ENTRIES IN 注意点 ABAP-根据T-CODE找BADI ABAP-根据T-CODE找BAPI ABAP-UPLOAD文件时常用的数据转换 关于using和changing 程序之间的调用 报表中所用到的事件以及作用 SAP-ABAP SELECT-SCREEN 的几...

    SAP-ABAP-SQL中的select语句讲解

    ABAP中SQL语法详细介绍,包括基础语法和各种聚合函数,如MAX,MIN,AVG,COUNT,SUM,DIV,MOD,CEIL,FLOOR,DIVSION,ROUND,FOR ALL ENTRIES IN.除了各种聚合函数还有字段拆分,连接,子语句查询,字段类型转换,分情况赋值...

    Microservices for Java EE Architects-DVT Press(2016).azw3

    Readers of the Java EE Architect’s Handbook, Second Edition are well ... Additionally, reader questions are sometimes selected and answered in entries in my blog at http://www.derekashmore.com/.

    npp.8.0.Installer.x64.exe

    13. Fix duplicated entries in Auto-Completion pop-up window. 14. Fix Python Function List not showing functions in some circumstance. 15. Enhance Folder as Workspace performance while adding/removing ...

    npp.8.0.portable.x64.7z

    13. Fix duplicated entries in Auto-Completion pop-up window. 14. Fix Python Function List not showing functions in some circumstance. 15. Enhance Folder as Workspace performance while adding/removing ...

    npp.8.0.portable.x64.zip

    13. Fix duplicated entries in Auto-Completion pop-up window. 14. Fix Python Function List not showing functions in some circumstance. 15. Enhance Folder as Workspace performance while adding/removing ...

    a project model for the FreeBSD Project.7z

    There is no defined model for how people write code in FreeBSD. However, Niels Jørgenssen has suggested a model of how written code is integrated into the project. Figure 4-1. Jørgenssen's model ...

    ActionScript3.0

    and special types Packages Alphabetical entries for class elements An index containing all entries An appendix that compares some key language and API changes from ActionScript 2.0 to ...

    zynq_canutils.zip

    rcvlist_all - list for unfiltered entries (no filter operations) rcvlist_eff - list for single extended frame (EFF) entries rcvlist_err - list for error message frames masks rcvlist_fil - list for ...

    VclZip pro v3.10.1

    PLEASE TAKE A LOOK AT THE "WHAT's NEW IN THIS VERSION" LINK IN THE HELP FILE AS IT HAS CONVENIENT LINKS TO ALL OF THE NEW TOPICS. ==================== Version 3.10 Build 1 - Several bug fixes. - ...

    Databox – Data editor save solution v1.2.1p1

    Static keys generator for accessing tables, entries and values (instead of strings) Demo scenes included PlayMaker support FlowReactor support Powered by FullSerializer and OdinSerializer ...

    微软内部资料-SQL性能优化5

    A clustered index is like a telephone directory in which all of the rows for customers with the same last name are clustered together in the same part of the book. Just as the organization of a ...

    Editor Console Pro 3.94

    - Use a search field to filter all entries by text, file name, class, GameObject name on the fly. - Search and filter using Regular Expressions. - Create custom filter groups with their own colors, ...

    Tajima 绣花机 花型数据编码格式

    All entries in the header seem to be 2 ASCII characters followed by a colon, then it’s value trailed by a carriage return. First is the ‘LA’ entry, which is the design name with no path or ...

    8-07-14_MegaCLI for linux_windows

    LSIP200232954 (DFCT) Need to Support all the MFC default values in the command AdpSettings. LSIP200245968 (DFCT) In EFICLI not able to flash latest firmware to controller without using -nosigchk -...

    Your Excel Survival Kit: Your Guide to Surviving and Thriving in an Excel world

    Your Excel Survival Kit: Your Guide to Surviving and Thriving in an Excel world By 作者: Anne Walsh ...Identifying Duplicate Entries in a List Simple Normalization(Getting Crossways Data to Go

    mask rcnn paper

    R-CNN by adding a branch for predicting an object mask in parallel with the existing branch for bounding box recognition. Mask R-CNN is simple to train and adds only a small overhead to Faster R-CNN, ...

Global site tag (gtag.js) - Google Analytics