0% found this document useful (0 votes)
16 views6 pages

Performance Imporvement Techniques

The document outlines performance improvement strategies for SAP programs, emphasizing the use of tools like SE30, ST05, and ST12 for runtime analysis and SQL tracing. It provides guidelines for writing efficient queries, such as ensuring field order matches database fields, using binary search on sorted internal tables, and employing parallel cursors for nested loops. Additionally, it advises against hard coding and recommends maintaining dynamic entries in custom tables to enhance program flexibility.

Uploaded by

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

Performance Imporvement Techniques

The document outlines performance improvement strategies for SAP programs, emphasizing the use of tools like SE30, ST05, and ST12 for runtime analysis and SQL tracing. It provides guidelines for writing efficient queries, such as ensuring field order matches database fields, using binary search on sorted internal tables, and employing parallel cursors for nested loops. Additionally, it advises against hard coding and recommends maintaining dynamic entries in custom tables to enhance program flexibility.

Uploaded by

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

Perfomance imporvement of the program or Standards follow when write the program:

SAP HAS Provided tools :

SE30 - Run time analsyis

ABAP how much time


DATA base how much time
system how much time

ST05 - Sql Trace


select query how much time taking time we can see in Sql trace
which index is triggering also we can see in ST05

ST12 - Both run time analayis and Sql trace


additionally we can see specifi subroutine how much time it is taking
and loop how much time is taking we can able to see

a) The fields order should be always match with data base fields order .
in where condition always follow the data base sequnece only
( base on this seuence only index will trigger )

select
MTART - currency
MATNR -12 char
where mtart =
and mtanr =
will get the dump if data types mismatch .

b) when ever we are writing the for all entries we need kept the condition
for all entries internal table should not be empty .

it will pick all the entries from the second table.

it will delete the adjecnet duplicates automatically when fetch from data base
table.

please maintain the key fields of the table .

select ebeln
ebelp
from ekpo
into table it_ekpo
for alll entries in it_ekko
whre ebeln eq it_ekko-ebeln.

for all entries pre requiste :


For all entries internal table should not be empty
data type and lenght should match in where condtion ( same ).

IT_TEST --- TEST( field name ) non key filed


TEST - NON KEY FIELD
DELETE IT_TEST WHERE TEST IS INITIAL.

IT_BEST -
BEST - TEST KEY FIELD

IF IT_TEST IS NOT INITIAL.

SELECT TEST
FROM BEST
INTO TABLE IT_BEST
FOR ALL ENTRIES IN IT_TEST
WHERE TEST E IT_TEST-TEST.

ENDIF.

if it_mara is not initial.


select matnr
maktx
from makt
into table it_makt
for all entries in it_mara
where matnr eq it_mara-mat

endif.

select matnr
maktx
form marc
into table it_marc.

b) if you fetcthing the data from the data base based on the non key fields it will
take time
to get the data from the data base then we will go with secondary index concept to
improve the performance.

c) in read staments we can apply binary search before that we need to sort the
internal table.

sort it_ekpo by ebeln posnr matnr .

binaey search prereuqites is sort the internal table.

read it_ekpo into wa_ekpo with key ebeln = wa_final-ebeln " 100
posnr = wa_final-posnr 10
matnr = wa_final-matnr 123 binrary search.

Binary search will follow the binary search algoritham .

it will always work for asending .


read itab into wa with key num = '8'.

1
2
3
4
5 -----------
6
7
8
9
10

mid value = 5
search value = 8

it will identify the mid value

mid value < search value

if search value is more than the middle value then it will ignore the upper half
and
it will go to lower half .

mid value = 5
search value = 4

mid value > search value

if search value is less than the middle value then it will ignore the lower half
and
it will go to upper half .

1
2
3
6
7 - mid value
5
4
8
9
10

mid value = 7

search value = 4

mid value > searh value


if search value is less than the middle value then it will ignore the lower half
and
it will go to upper half .

binray seaerch will not work for desnding

10
9
8
7
6
5 - Mid value
4
3
2
1

mid vlaue = 5
search value = 8

mid value < search value

if search value is more than the middle value then it will ignore the upper half
and
it will go to lower half .

Any nested loops we can use Parllel cursor to improve the performance .
sort the both internal tables with common key field.

sort it_customer by kunnr.


sort it_bank by kunnr .

IT_CUSTOMER
KUNNR

SRAVANI
SATISH
KIRAN
KISHORE

IT_BANK
KUNNR BANK

SRAVANI ICICI 1
SRAVANI SCB 2
SRAVANI AXIS 3
SATISH ICICI 4
SATISH KOTAK 5
SATISH AXIS 6
KIRAN ICIC 7
KIRAN SBI 8
KISHORE ICICI 9
KISHORE SBI

inside loop will follow the linear search one by one

loop the first internal table .

read the second internal table passing common key field

if entry found then we can pass the sy-tabix value into local index variable .

loop the second internal table from index postion

inside that fist internal table work area value ne second internal tabl work
area value then we wil write
exit stanment.

loop at it_customer into wa_customer. satsih upper loop

read table it_bank into wa_bank with key kunnr = wa_customer-kunnr binray search .
" staish

if sy-subrc eq 0 .
lv_index = sy-tabix. 4 ( it will identify the processing record position in loop
).

loop at it_bank into wa_bank from lv_index. ( 4)


if wa_customer-kunnr < > wa_bank-kunnr .
exit. " it will skip the inner loop
endif.
endloop.

endif.

endloop.

Always avoid hard coding in the program .

lets suppose we have implemented report which will pick the only 1000 company codes

and moved to QE3 and PE3 . later user comes with requirement the report needs to
pick
2000 company code as well. in that case we need to change the program again .

to avoid thses kind of things we will maintain the company code enrties in Custom
table
and create tMG.

so in future any company code added we can matain the enrties in custom tavle no
need to touch the program

1000 + 2000 + 3000 company code

we need to change the program


DE3 - QE3 - PE3

select vbeln
bukrs
from vbak
into table it_vbak
whre vbeln in s_vbeln
and bukrs in ( '1000' , '2000' ).

dont write the select stament with in the loop.

loop it_mara into wa_mara .

select matnr
maktx
from makt
where matnr eq wa_mara-matnr.

endloop.

You might also like