You are on page 1of 6




4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21

22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 .

37 38 39 40 .

Use the results of the above checks to remove all variables/constants etc that are declared but are not used) Transaction SE30 (ABAP Runtime Analysis) must be checked to measure/compare program performance/runtime if program has multiple inefficient databases selects or complicated internal table operations Use transaction ST05 (SQL Trace) to see what indices your database accesses are using. but do not forget to check the impact by consulting onsite coordinator. Create new indices if necessary. “For all Entries” is to be used over “Loop at ITAB / Select / ENDLOOP” (FOR ALL ENTRIES retrieves a unique result set so ensure you retrieve the full key from the database) When creating joins over database tables there should be an index at least on the inner table for the fields in the join condition else use “ FOR ALL ENTRIES” select statement Usage of JOIN is limited to a maximum of 2 i. not more than 3 database tables are joined at one time CHECK that the internal table used in FOR ALL ENTRIES is NOT empty as this will retrieve all Delete adjacent duplicate entries from internal table before selection from database table using “ FOR ALL ENTRIES” statement For copying internal tables use „=‟ operator instead of Looping & Appending SORT inside a LOOP is not used .. “SELECT UP to 1 Rows” is used.e.Description Run Extended syntax checks with character literals checkbox switched on & Code Inspector to rectify all relevant errors and warning (e. Check other indices for this table and where you have to change your “where” clause to use it. when the internal table will be greater than 500. Use “Up to N Rows” when the number of records needed is known Select statement within a GET event is not used Wild cards like „A%‟ is avoided as much as possible Nested Select is not used instead “Inner Join” and/or “For all Entries” is used.g. Remember not always the data element name matches with the table field name Internal Table is defined with “TYPE STANDARD TABLE OF” & Work-Areas is used instead of header lines Global variables are minimized by declaring local variables or by passing variables through parameters & arguments while creating internal subroutine(s) In SELECT statement. except when the table will be very large (i. TYPE (data element) command is used while declaring the fields whenever feasible instead of LIKE.000 records).e. “Select Single” is used only when full primary key combination is known No SELECT * is used Use “SELECT INTO TABLE” rather than “SELECT INTO CORRESPONDING FIELDS OF TABLE” Always specify as many primary keys as possible in WHERE clause to make the Select efficient Always select into an internal table. only the required fields are selected in the same order as they reside on the database table/structure/view For selecting single row from a database table. Check these indices against your “where” clause to assure they are significant.

WHERE condition for a set of line. Also CASE is used instead of IF when testing multiple fields “equal to” something LOOP AT ITAB INTO WORKAREA WHERE K = „XXX‟ should be used instead of LOOP AT ITAB INTO WORKAREA / CHECK ITAB-K = „XXX‟. SORT ITAB BY FLD1 FLD2 ASCENDING) Hashed table is used for processing large amount of data (provided that you access single records only.g. which are used in a READ TABLE statement using BINARY SEARCH.Sort internal table by fields in the correct order. Whenever possible formulate SQL statements positively When coding IF or CASE. Use the MODIFY ITAB .. Use CHECK or IF…EXIT…ENDIF as appropriate to exit from the loop Sort fields and Sort Order on the SORT statement should be mentioned explicitly (e. testing conditions are nested so that the most frequently true conditions are processed first.g. for single line.. the work area that has been appended is cleared Internal tables. If the order of sorting is invalid the BINARY SEARCH will never work For large internal tables where only some rows are to be processed. Also READ TABLE INTO WORKAREA should be used instead of only READ TABLE... TRANSPORTING f1 f2 .. and MODIFY ITAB . using the FREE / REFRESH command). Do not use: LOOP AT ITAB WHERE EQUNR = „00001011‟. After the APPEND statement inside a loop.. Work areas & Global Variables are freed when no longer needed (e.. ENDLOOP. Use: DELETE ITAB WHERE EQUNR = „00001011‟. to accelerate the updating of internal table If possible. TRANSPORTING f1 f2 . Update/Insert statement is used instead of Modify Is the following steps ensured during database updates? Lock data to be edited Read current data from the database Process data and write it to the database Release the locks set at the beginning . DELETE ITAB. and all with a fully specified key) DELETE or SORT is not used on a hashed table since it increases memory consumption Sorted table is used for range accesses involving table key or index accesses Fields specified in the WHERE condition with the critical operators NOT and <> (negative SQL statements) cannot be used for a search using database indexes.. especially when the tables are large or the program is a batch program Do not delete the records of internal table inside the Loop – End loop. use SORT and then the READ TABLE command is used to set index to first relevant row before looping from that index.

Try to avoid logical databases. Min) functions in the database selection Use Parallel Cursor methods for nested loop into the internal tables if second internal table contains considerable number of records In Smartform/ Sapscript do not make redundant data retrieval where data is available in interface . Max. always use the FIELDS addition to reduce the amount of data selected by the logical database Avoid the aggregate (Count. If your program uses a logical database. but does not require all fields belonging to a certain GET event.

39708 894 -0:80/4.39708 8:80/  47.47 47.9%.07 445.


039/:5.:83/.041 8290/94.-083.99024891706:03997:0.89439033079.934384.9430 920 9..088083.7094-0574.075488-01472:.70.3/$479 7/074390$ #%89..902039:83 #$# 19047/07418479383.9.90$" 89. 0090.10/390#.80/9./90#$#30..24:3941/.3/.3974-01470445317429.39.90203984:/-02039430/05.3/.80.08883070.9431742/.#%89.9.4507.422.0880/ :80$ #%.-0-01470800.43/9438.-0:83   #%#$ 89.0883.909409174290445 $47910/8.9.-0-10/8390.43/943990.-.2:241 0 34924709.70430/.94:..809.9.90203985489.9.99039073.93/0 &80 47 % .70.3/ 30.-08:80  4507.0747 47.33/0.-.89870970.9.9.-08070438420748. 574.-014790 10/839043.3349-0:80/147.3/90390# %.902039 47.80/9./.9.30. !8349:80/            $47939073.3/8:80/948093/0941789700. 84$8:80/3890.803/008 030.947/07 .7039073.94  842093  !%%%  ###  84:/-0:80/3890..08808 0/8850.9473890.7030890/849.70:80/3.-0:80/3 #%#$8 %0259.07/.-08:80/1477..10/0 %47$ #%8349:80/43./0/9./414453 5503/3 $ #%38/0.9478 %.4/347$ 90893. .43/943080:80  #%#$ 800..438:25943 $4790/9.80820247.70574./4103908932:95010/8 06:.80 03.-08907084:/-0.902039 &8.0 03.90.-08:80/147574.4770.809.-08.-.-00473/0.809.47/8 43 .9 0  $ #%% $ .7.9020398 .0$" 89..989.4.79..093.9.. !   #%#$70970.:36:0708:9 80984038:704:70970./41 !% %%  ##...45339073.-.

0.5503/0/8.'.7.70.701700/03344307300/0/ 0  :8390 #.70/ 39073.8-003.9.-08 47.90203938/0.70./4143#% 190790!!89.9.445 9047.%    84#%%  ##84:/-0:80/3890.-08.8 4-.9.

03909.422.. 5747.7047905747.9.-0 .70.9090:5/.##$. 9.-.2 4349/00909070..3/ %  %#$! #%11 #.934139073.3/ 0850.43/943147.28.9.007.-038/090445 3/445 4349:80 %%  ! !%%#"&#    &80%%#"&#    &8090 % %#$! #%11 14783030 .8094130 94.-08.47/84139073..

  15488-0 &5/.90.

80904./.3%0.4/90.990-0333 %794.9.80 -:9/408349706:70.4/ 14:75747.2:808.039 .791472.9...47/8 3$2.3807989.9.-0.38 .0:78472094/814730890/4453949039073.9.943 &80!.439./.-.8:8090$.800.80800.9..24:3941 /.7.     10/8-043394.9.80 !74.8809./.079./.9.:77039/.4.80 . 3 1:3..-.-.9...-08180.9.80 #00.9020398:80/3890.//9439470/:..80:5/./.-03:2-074170.9./414/1 890144389058038:70//:73/.174290/.9438390/.-.90 4:39 .-.90/-904.70.088/.-.438/07.9.908 4.9.3/79099490/.94-00/90/ #0.-.43/39073.

..-0339071.9.8.0 .9.58.070/:3/.070/.70970.759/43492.$...39/..