How to adjust the performance of the ABAP program

Source: Internet
Author: User

1. Use the where statement
Not recommended
Select * From zflight.
Check: zflight-airln = 'lf 'and zflight-fligh = 'bw222 '.
Endselect.
Recommendation
Select * From zflight where airln = 'lf 'and fligh = '000000 '.
Endselect.

2. Using Aggregate functions
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 '.

3. Use view instead of basic table query
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.

4. Use into table instead of select endselect
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.

5. Use batch modification of internal tables instead of Row-by-row modification
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.

6. Use the binary query method to increase the speed of querying internal table data
Not recommended
Read Table int_fligh with key airln = 'lf '.
Recommendation
Read Table int_fligh with key airln = 'lf 'binary search.

7. Use batch add to add two internal tables instead of Row-by-row
Not recommended
Loop at int_fligh1.
Append int_fligh1 to int_fligh2.
Endloop.
Recommendation
Append lines of int_fligh1 to int_fligh2.

8. Use table buffering
Use of buffered tables is recommended to improve the performance considerably. the buffer is bypassed while using the following statements
select distinct
select... For update
order by, group, having clause
joins
use the bypass buffer addition to the select clause in order to explain icitly bypass the buffer while selecting the data.

9. Use for all entries
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.

10. Use the where statement correctly to enable indexing for queries
When a base table has multiple indices, the where clause shocould be in the order of the index, either a primary or a secondary index
To choose an index, the optimizer checks the field names specified in the WHERE clause and then uses an index that has the same order of the fields. one more tip is that if a table begins with mandt, while an index does not, there is a high possibility that the optimizer might not use that index.

11. Use the move statement correctly
Instead of using the move-corresponding clause it is advisable to use the move statement instead. attempt shoshould be made to move entire internal table headers in a single shot, rather than moving the fields one by one.

12. Use Inner join correctly
 Let us take an example of 2 tables, zairln and zflight. the table zairln has the field airln, which is the airline code and the field lnnam, which is the name of the airline. the table zflight has the field airln, the airline code and other fields which hold the details of the flights that an airline operates.
Since these 2 tables a re logically joined by the airln field, it is advisable to use the inner join.
Select ~ Airln ~ Lnnam B ~ Fligh B ~ Cntry into Table int_airdet
From zairln as a inner join zflight as B on ~ Airln = B ~ Airln.
In order to restrict the data as per the selection criteria, a where clause can be added to the above inner join.

13. Use sort by instead of order

14. Avoid using the select distinct statement
ABAP replace sort + Delete adjacent duplicates.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.