Beruflich Dokumente
Kultur Dokumente
ABAP Training
3 Major Areas
Select statements
Internal table usage
Database index
ABAP Training
Select Statements
Ensure that data is selected with primary key /secondary index support
with the fields in the select statements WHERE clause in the same order
as fields in the index
Avoid negative WHERE clause (NE) because negative where clauses
disable the index
Avoid long selects within AT SELECTION-SCREEN event
ABAP Training
Select up to 1 rows when 'where' clause fields <> 'primary key fields
E.G. Select MATNR UPTO 1 rows from VBAP
Where VBELN = 0001500080
Select single when 'where' clause fields = 'primary key fields'
E.G. Select single AUDAT VBTYP from VBAK
Where VBELN = 0001500080
ABAP Training
ABAP Training
Select fields only instead of select *, when no. Of fields < 1/3rd of total
fields in table or no. Of fields getting selected less than or equal to 16.
Use SAP standards views for multiple table data selection
Data should not be selected within loop .. Endloop statements. Instead
use the select statement in join or for for all entries
ABAP Training
ABAP Training
ABAP Training
Check whether the internal table has records in it before executing the
validation checks and related processing steps for that internal table.
Example before for all entries in itab1, loop at itab1
It is more efficient to use the AT statements ( AT NEW, AT END OF, AT
LAST ...) for summing and control breaks purpose. Avoid using ON
CHANGE OF
If using loop at WHERE statement never use internal tables events
such as AT new inside the loopEndloop
ABAP Training
All internal table reads with binary search only, after sorting it on the
'with key' fields
To add data to an internal table and keep it sorted, use a READ with
BINARY SEARCH followed by an INSERT rather than using the APPEND
statement followed by the SORT statement
E.G. Read table INT_table with key INT_table
binary search.
If SY-SUBRC <> 0.
Insert INT_table index SY-TABIX.
ENDIF
10
ABAP Training
11
ABAP Training
12
ABAP Training
13
ABAP Training
Database Index
14
ABAP Training
Creating Indexes
15
ABAP Training
16
ABAP Training
17
ABAP Training
Using Indexes
When selecting data from a table, look at the structure of all of the
available indexes and tailor the WHERE clause to take advantage of the
most selective index. Use all fields in the WHERE clause in the same
order for an index, as skipping one field disables the index
Be sure to order the columns in the WHERE clause of a SELECT in the
same order as an index table
18
ABAP Training
19
ABAP Training
20
ABAP Training
21
ABAP Training
Memory Costs
22
ABAP Training
Points to Be Considered
Each index slows down the inserts into the table. Updates are only
slowed down if indexed fields are updated. On the other hand, the
indexes increase the efficiency of reads. These tradeoffs must be
weighed against one another. In general, frequently updated tables
should have only few indexes while frequently selected tables might
have more
Remove unused indexes or ones that change due to report design
changes
23
ABAP Training
Points of Caution
24
ABAP Training
Runtime analysis
SQL trace
25
ABAP Training
26
ABAP Training
Runtime Analysis
27
ABAP Training
SQL Trace
Allows you to monitor the database access from reports and transactions
Allows you to see how the OPEN SQL statements that you use in ABAP
programs are converted to standard SQL statements
28
ABAP Training
29