SAP ABAP Performance Tuning Tips & Tricks

学习abap近一个月

自我感觉进步不小

要感谢同事无私帮助

[@more@]

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 = 慙F� and zflight-fligh = 態W222�.

Endselect.

Recommended

Select * from zflight where airln = 慙F� 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 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 慖N%�.

Select single * from zflight where cntry = zcntry-cntry and airln = 慙F�.

Endselect.

Recommended

Select * from zcnfl where cntry like 慖N%� and airln = 慙F�.

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 = 慩�.

Endif.

Modify int_fligh.

Endloop.

Recommended

Int_fligh-flag = 慩�.

Modify int_fligh transporting flag where flag is initial.

Appending 2 internal tables

Instead of using the normal loop-endloop approach for this kind of programming, use the variation of the append command. Care should be taken that the definition of both the internal tables should be identical.

Not Recommended

Loop at int_fligh1.

Append int_fligh1 to int_fligh2.

Endloop.

Recommended

Append lines of int_fligh1 to int_fligh2.

Use of ABAP Sort instead of Order By

The order by clause is executed on the database server, while the sort statement is executed on the application server. Thus instead of giving the order by in the select clause statement, it is better to collect the records in an internal table and then use the sort command to sort the resulting data set.

Use of FOR ALL Entries

Outer join can be created using this addition to the where clause in a select statement. It speeds up the performance tremendously, but the cons of using this variation are listed below

  1. Duplicates are automatically removed from the resulting data set. Hence care should be taken that the unique key of the detail line items should be given in the select statement.
  2. If the table on which the For All Entries IN clause is based is empty, all rows are selected into the destination table. Hence it is advisable to check before-hand that the first table is not empty.
  3. If the table on which the For All Entries IN clause is based is very large, the performance will go down instead of improving. Hence attempt should be made to keep the table size to a moderate level.

Not Recommended

Loop at int_cntry.

Select single * from zfligh into int_fligh

where cntry = int_cntry-cntry.

Append int_fligh.

Endloop.

Recommended

Select * from zfligh appending table int_fligh

For all entries in int_cntry

Where cntry = int_cntry-cntry.

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

转载于:http://blog.itpub.net/112322/viewspace-1027490/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值