TEC BAS 10 - ABAP Performance Tips & Tricks - v2003
TEC BAS 10 - ABAP Performance Tips & Tricks - v2003
Enrik Gugliandolo
v1.0 / 23.03.2010
Your best friends
• ABAP Runtime Analysis SE30
2
ABAP Runtime Analysis (Transaction SE30)
3
Memory Layers
5
Memory usage (Transaction SM04)
6
System analysis (Transaction ST02)
7
Database Layers
Presentation
PresentationLayer
Layer(SAPgui, RFC, Web dynpros etc…)
(SAPgui, RFC, Web dynpros etc…)
ABAP
ABAPstack
stack
Database abstraction
Database
Database(Oracle, DB2, MS SQL, MaxDB etc…)
(Oracle, DB2, MS SQL, MaxDB etc…)
SQL trace (Transaction ST05)
9
SQL trace (Transaction ST05)
10
Indexes (Transaction SE11)
11
Indexes (Transaction SE11)
12
Performance Tips and Tricks for ABAP
• From SE30
• From SE80
13
Performance Tips and Tricks for ABAP
14
Performance Tips and Tricks for ABAP
• Some obvious example of optimization
REFRESH ITAB2.
LOOP AT ITAB1 INTO WA.
APPEND WA TO ITAB2.
ENDLOOP.
ITAB2[] = ITAB1[].
16
Typed vs. untyped Parameters 1/2
• Untyped parameters (Runtime: 6 microseconds)
17
Typed vs. untyped Parameters 2/2
• Typed parameters (Runtime: 2 microseconds)
18
Select ... Where vs. Select + Check
• Select + Check statement (Runtime: 258 microseconds)
19
Select aggregates
• Select ... Where + Check (Runtime: 3721 microseconds)
20
Nested loops
• Straightforward nested loop (Runtime: 11245 microseconds)
I = 1.
LOOP AT ITAB1 INTO WA1.
LOOP AT ITAB2 INTO WA2 FROM I.
IF WA2-K <> WA1-K.
I = SY-TABIX.
EXIT.
ENDIF.
" ...
ENDLOOP.
ENDLOOP.
21
Buffered vs Unbuffered tables
22
Native SQL
• Open SQL allows you to access database tables declared in the
ABAP Dictionary regardless of the database platform that you R/3
System is using. Bypassing the abstraction layer (no sync, no
buffering, nada!).
EXEC
EXECSQL
SQL[PERFORMING
[PERFORMING<form>].
<form>].
<Native
<NativeSQL
SQLstatement>
statement>
ENDEXEC
ENDEXEC
23
Native SQL
• Coding sample
EXEC
EXECSQL
SQLPERFORMING
PERFORMINGloop_output.
loop_output.
SELECT
SELECTconnid,
connid,cityfrom,
cityfrom,cityto
cityto
INTO
INTO :wa
:wa
FROM
FROM spfli
spfli
WHERE
WHERE carrid
carrid==:c1
:c1
ENDEXEC.
ENDEXEC.
FORM
FORMloop_output.
loop_output.
WRITE:
WRITE:/ /wa-connid,
wa-connid,wa-cityfrom,
wa-cityfrom,wa-cityto.
wa-cityto.
ENDFORM.
ENDFORM.
24
General Rules
• Avoid direct modifications (INSERT, UPDATE, MODIFY o DELETE)
to standard SAP tables.
• Always try to use SAP standard function (SDN is your friend!)
• Avoid * , always try to add specifically witch field you want to read in
the select.
• Always put “where” “and” statement in a select in the correct
table/indexes order.
25
Questions?
26