设为首页 收藏本站
查看: 618|回复: 0

[经验分享] SAP ABAP Performance Tuning Tricks Introduction/介绍下ABAP的性能调整窍门

[复制链接]

尚未签到

发表于 2015-9-19 13:14:48 | 显示全部楼层 |阅读模式
Need for performance tuning
In this world of SAP programming, ABAP is the universal language. In most of the projects, the focus is on getting a team of ABAP programmers as soon as possible, handing over the technical specifications to them and asking them to churn out the ABAP programs within the “given deadlines”.
Often due to this pressure of schedules and deliveries, the main focus of making a efficient program takes a back seat. An efficient ABAP program is one which delivers the required output to the user in a finite time as per the complexity of the program, rather than hearing the comment “I put the program to run, have my lunch and come back to check the results”.
Leaving aside the hyperbole, a performance optimized ABAP program saves the time of the end user, thus increasing the productivity of the user, and in turn keeping the user and the management happy.
This tutorial focuses on presenting various performance tuning tips and tricks to make the ABAP programs efficient in doing their work. This tutorial also assumes that the reader is well versed in all the concepts and syntax of ABAP programming.
NOTE: Performance of a program is also often limited due to hardware restrictions, which is out of the scope of this article.

  
===================================================================================

This tutorial contains a number of pages, each one explaining a tip or trick. You can either browse them one by one (click on the NEXT button, or jump straight to a tip or trick which interests you:


  • Introduction (this page)
  • Selection criteria
  • Aggregate functions
  • Views instead of base tables
  • The "into table" clause
  • Modifying a group of lines
  • Use of binary search option
  • Appending two internal tables
  • Table buffering
  • Use of "for all" entries
  • Proper structure of "where" clause
  • Proper use of "move" statement
  • Proper use of "inner join"
  • Use of "ABAP Sort" instead of "Order By"
  • Tools for analysis of performance
  
Use of selection criteria 使用标准查询

Instead of selecting all the data and doing the processing during the selection, it is advisable to restrict the data to the selection criteria itself, rather than filtering it out using the ABAP code.

Not recommended

            Select * from zflight.

             Check : zflight-airln = ‘LF’ and zflight-fligh = ‘BW222’.

            Endselect.

Recommended

   
        Select * from zflight where airln = ‘LF’ and fligh = ‘222’.

            Endselect.

One more point to be noted here is of the select *. Often this is a lazy coding practice. When a programmer gives select * even if one or two fields are to be selected, this can significantly slow the program and put unnecessary load on the entire system. When the application server sends this request to the database server, and the database server has to pass on the entire structure for each row back to the application server. This consumes both CPU and networking resources, especially for large structures.

Thus it is advisable to select only those fields that are needed, so that the database server passes only a small amount of data back.

Also it is advisable to avoid selecting the data fields into local variables as this also puts unnecessary load on the server. Instead attempt must be made to select the fields into an internal table.
  
Use of aggregate functions 使用聚和函数

Use the already provided aggregate functions, instead of finding out the minimum/maximum values using ABAP code.

Not recommended

            Maxnu = 0.

            Select * from zflight where airln = ‘LF’ and cntry = ‘IN’.

             Check zflight-fligh > maxnu.

             Maxnu = zflight-fligh.

            Endselect.



Recommended

            Select max( fligh ) from zflight into maxnu where airln = ‘LF’ and cntry = ‘IN’.
The other aggregate functions that can be used are min (to find the minimum value), avg (to find the average of a Data interval), sum (to add up a data interval) and count (counting the lines in a data selection).
  
Use of Views instead of base tables 利用视图代替基本表

Many times ABAP programmers deal with base tables and nested selects. Instead it is always advisable to see whether there is any view provided by SAP on those base tables, so that the data can be filtered out directly, rather than specially coding for it.

Not recommended

            Select * from zcntry where cntry like ‘IN%’.

             Select single * from zflight where cntry = zcntry-cntry and airln = ‘LF’.

            Endselect.



Recommended

            Select * from zcnfl where cntry like ‘IN%’ and airln = ‘LF’.

            Endselect.

===================================================================================
  
Use of the into table clause of select statement 在选择语句时使用插入表子句

Instead of appending one record at a time into an internal table, it is advisable to select all the records in a single shot.

Not recommended

            Refresh: int_fligh.

            Select * from zflight into int_fligh.

             Append int_fligh. Clear int_fligh.

            Endselect.



Recommended

  
          Refresh: int_fligh.

            Select * from zflight into table int_fligh.

===================================================================================

  
Modifying a group of lines of an internal table 在内表中修改一组行

Use the variations of the modify command to speed up this kind of processing.

Not recommended

            Loop at int_fligh.

             If int_fligh-flag is initial.

                        Int_fligh-flag = ‘X’.

             Endif.

             Modify int_fligh.

            Endloop.



Recommended

            Int_fligh-flag = ‘X’.

            Modify int_fligh transporting flag where flag is initial.

===================================================================================

  
Use of binary search option 使用折半查询

When a programmer uses the read command, the table is sequentially searched. This slows down the processing. Instead of this, use the binary search addition. The binary search algorithm helps faster search of a value in an internal table. It is advisable to sort the internal table before doing a binary search. Binary search repeatedly divides the search interval in half. If the value to be searched is less than the item in the middle of the interval, the search is narrowed to the lower half, otherwise the search is narrowed to the upper half.

Not Recommended

            Read table int_fligh with key  airln = ‘LF’.



Recommended

            Read table int_fligh with key  airln = ‘LF’ binary search.

===================================================================================



运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-115854-1-1.html 上篇帖子: 最大流 Dinic + Sap 模板 下篇帖子: 关于SAP职位的薪酬报告
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表