0% found this document useful (0 votes)
38 views26 pages

TEC BAS 10 - ABAP Performance Tips & Tricks - v2003

This document provides tips and tricks for improving ABAP performance. It recommends using transactions like SE30, ST05, and SE11 to analyze runtimes, SQL traces, and indexes. Specific tips include copying tables using assignments instead of loops, using typed parameters, using WHERE clauses instead of SELECT + CHECK, and leveraging aggregates and parallel cursors in nested loops. Native SQL is suggested as a last resort. Overall, it emphasizes optimizing SELECT statements, avoiding direct table modifications, and using SAP standard functions whenever possible.

Uploaded by

piluso
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views26 pages

TEC BAS 10 - ABAP Performance Tips & Tricks - v2003

This document provides tips and tricks for improving ABAP performance. It recommends using transactions like SE30, ST05, and SE11 to analyze runtimes, SQL traces, and indexes. Specific tips include copying tables using assignments instead of loops, using typed parameters, using WHERE clauses instead of SELECT + CHECK, and leveraging aggregates and parallel cursors in nested loops. Native SQL is suggested as a last resort. Overall, it emphasizes optimizing SELECT statements, avoiding direct table modifications, and using SAP standard functions whenever possible.

Uploaded by

piluso
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 26

ABAP Performance Tips & Tricks

Enrik Gugliandolo
v1.0 / 23.03.2010
Your best friends
• ABAP Runtime Analysis  SE30

• SQL Performance Analysis  ST05

• Indexes: Transaction SE11  Display  Indexes

• Performance Tips and Tricks for ABAP (see nexts slides)

• Process overview  SM50

• Memory usage  ST04

• System Analysis  SE30

2
ABAP Runtime Analysis (Transaction SE30)

3
Memory Layers

ABAP Extended Swap (OS)


ABAPstack
stack (Work process memory)
Private (Paging)
Process overview (Transaction SM50)

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

• Time mesured on Belgium servers, numbers could change


depending on system landscapes.
15
Copying internal tables
• Pedestrian way to copy internal tables (Runtime: 27 microseconds)

* Entries: 100, Line width 100

REFRESH ITAB2.
LOOP AT ITAB1 INTO WA.
APPEND WA TO ITAB2.
ENDLOOP.

• Let the kernel do the work (Runtime: 0 microseconds)

* Entries: 100, Line width 100

ITAB2[] = ITAB1[].

16
Typed vs. untyped Parameters 1/2
• Untyped parameters (Runtime: 6 microseconds)

PERFORM UP1 USING 10 M6-DIMID M6-ZAEHL M6-ISOCODE M6-ANDEC M6-PRIMARY.

FORM UP1 USING


REPEAT
DIMID
ZAEHL
ISOCODE
ANDEC
PRIMARY.
* Identical source code left and right:
DO REPEAT TIMES.
T006_WA-DIMID = DIMID.
T006_WA-ZAEHL = ZAEHL.
T006_WA-ISOCODE = ISOCODE.
T006_WA-ANDEC = ANDEC.
T006_WA-PRIMARY = PRIMARY.
ENDDO.
ENDFORM.

17
Typed vs. untyped Parameters 2/2
• Typed parameters (Runtime: 2 microseconds)

PERFORM UP2 USING 10 M6-DIMID M6-ZAEHL M6-ISOCODE M6-ANDEC M6-PRIMARY.

FORM UP2 USING


REPEAT TYPE I
DIMID LIKE T006-DIMID
ZAEHL LIKE T006-ZAEHL
ISOCODE LIKE T006-ISOCODE
ANDEC LIKE T006-ANDEC
PRIMARY LIKE T006-PRIMARY.
* Identical source code left and right:
DO REPEAT TIMES.
T006_WA-DIMID = DIMID.
T006_WA-ZAEHL = ZAEHL.
T006_WA-ISOCODE = ISOCODE.
T006_WA-ANDEC = ANDEC.
T006_WA-PRIMARY = PRIMARY.
ENDDO.
ENDFORM.

18
Select ... Where vs. Select + Check
• Select + Check statement (Runtime: 258 microseconds)

SELECT * FROM SBOOK INTO SBOOK_WA.


CHECK: SBOOK_WA-CARRID = 'LH' AND
SBOOK_WA-CONNID = '0400'.
ENDSELECT.

• Select with Where condition (Runtime: 231 microseconds)

SELECT * FROM SBOOK INTO SBOOK_WA


WHERE CARRID = 'LH' AND
CONNID = '0400'.
ENDSELECT.

19
Select aggregates
• Select ... Where + Check (Runtime: 3721 microseconds)

DATA: MAX_MSGNR type t100-msgnr.


MAX_MSGNR = '000'.
SELECT * FROM T100 INTO T100_WA
WHERE SPRSL = 'D' AND
ARBGB = '00'.
CHECK: T100_WA-MSGNR > MAX_MSGNR.
MAX_MSGNR = T100_WA-MSGNR.
ENDSELECT.

• Select using an aggregate function (Runtime: 233 microseconds)

DATA: MAX_MSGNR type t100-msgnr.


SELECT MAX( MSGNR ) FROM T100 INTO max_msgnr
WHERE SPRSL = 'D' AND
ARBGB = '00'.

20
Nested loops
• Straightforward nested loop (Runtime: 11245 microseconds)

* Entries: 100 (ITAB1), 1000 (ITAB2)


* Line width: 100
* Both tables sorted by key K

LOOP AT ITAB1 INTO WA1.


LOOP AT ITAB2 INTO WA2
WHERE K = WA1-K.
" ...
ENDLOOP.
ENDLOOP.

• Sophisticated loop: parallel cursors (Runtime: 234 microseconds)


* Entries: 100 (ITAB1), 1000 (ITAB2)
* Line width: 100
* Both tables sorted by key K

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

If you want speed, don’t bypass buffers


RAM memory > Disk access

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!).

• Native SQL allows you to use database-specific SQL statements in


an ABAP program. This means that you can use database tables
that are not administered by the ABAP Dictionary, and therefore
integrate data that is not part of the R/3 System.

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.

Only use Native SQL as a last alternative!

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

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy