Select * from zflight.
Check : zflight-airln = ‘LF’ and zflight-fligh = ‘BW222’.
Select * from zflight where airln = ‘LF’ and fligh = ‘222’.
Maxnu = 0.
Select * from zflight where airln = ‘LF’ and cntry = ‘IN’.
Check zflight-fligh > maxnu.
Maxnu = zflight-fligh.
Select max( fligh ) from zflight into maxnu where airln = ‘LF’ and cntry = ‘IN’.
Select * from zcntry where cntry like ‘IN%’.
Select single * from zflight where cntry = zcntry-cntry and airln = ‘LF’.
Select * from zcnfl where cntry like ‘IN%’ and airln = ‘LF’.
4、使用INTO table 代替select endselect
Select * from zflight into int_fligh.
Append int_fligh. Clear int_fligh.
Select * from zflight into table int_fligh.
Loop at int_fligh.
If int_fligh-flag is initial.
Int_fligh-flag = ‘X’.
Int_fligh-flag = ‘X’.
Modify int_fligh transporting flag where flag is initial.
Read table int_fligh with key airln = ‘LF’.
Read table int_fligh with key airln = ‘LF’ binary search.
Loop at int_fligh1.
Append int_fligh1 to int_fligh2.
Append lines of int_fligh1 to int_fligh2.
Use of buffered tables is recommended to improve the performance considerably. The buffer is bypassed while using the following statementsSelect distinct
Select … for update
Order by, group by, having clause
Use the Bypass buffer addition to the select clause in order to explicitly bypass the buffer while selecting the data.
9、 使用FOR ALL Entries
Loop at int_cntry. Select single * from zfligh into int_fligh where cntry = int_cntry-cntry. Append int_fligh. Endloop.
Select * from zfligh appending table int_fligh
For all entries in int_cntry
Where cntry = int_cntry-cntry.
When a base table has multiple indices, the where clause should 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.
Instead of using the move-corresponding clause it is advisable to use the move statement instead. Attempt should be made to move entire internal table headers in a single shot, rather than moving the fields one by one.
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 a~airln a~lnnam b~fligh b~cntry into table int_airdet
From zairln as a inner join zflight as b on a~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、使用sort by 代替order by
使用的 ABAP SORT + DELETE ADJACENT DUPLICATES 代替.