<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: performance issues in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issues/m-p/1999102#M406783</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;1. Unused/Dead code &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Avoid leaving unused code in the program. Either comment out or delete the unused situation. Use program --&amp;gt; check --&amp;gt; extended program to check for the variables, which are not used statically. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. Subroutine Usage &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For good modularization, the decision of whether or not to execute a subroutine should be made before the subroutine is called. For example: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is better:&lt;/P&gt;&lt;P&gt;IF f1 NE 0. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PERFORM sub1. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDIF. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FORM sub1.&lt;/P&gt;&lt;P&gt;... &lt;/P&gt;&lt;P&gt;ENDFORM. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Than this: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PERFORM sub1. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FORM sub1.&lt;/P&gt;&lt;P&gt;IF f1 NE 0.&lt;/P&gt;&lt;P&gt;... &lt;/P&gt;&lt;P&gt;ENDIF. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDFORM. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3. Usage of IF statements &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When coding IF tests, nest the testing conditions so that the outer conditions are those which are most likely to fail. For logical expressions with AND , place the mostly likely false first and for the OR, place the mostly likely true first. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example - nested IF's: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF (least likely to be true). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF (less likely to be true). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF (most likely to be true).&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;ENDIF. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example - IF...ELSEIF...ENDIF : &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF (most likely to be true). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ELSEIF (less likely to be true). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ELSEIF (least likely to be true). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDIF. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example - AND: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF (least likely to be true) AND &lt;/P&gt;&lt;P&gt;(most likely to be true). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDIF. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example - OR: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF (most likely to be true) OR&lt;/P&gt;&lt;P&gt;(least likely to be true). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;4. CASE vs. nested Ifs&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When testing fields "equal to" something, one can use either the nested IF or the CASE statement. The CASE is better for two reasons. It is easier to read and after about five nested IFs the performance of the CASE is more efficient. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;5. MOVE statements &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When records a and b have the exact same structure, it is more efficient to MOVE a TO b than to MOVE-CORRESPONDING a TO b. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MOVE BSEG TO *BSEG. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;is better than &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MOVE-CORRESPONDING BSEG TO *BSEG. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;6. SELECT and SELECT SINGLE &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When using the SELECT statement, study the key and always provide as much of the left-most part of the key as possible. If the entire key can be qualified, code a SELECT SINGLE not just a SELECT. If you are only interested in the first row or there is only one row to be returned, using SELECT SINGLE can increase performance by up to three times. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;7. Small internal tables vs. complete internal tables &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In general it is better to minimize the number of fields declared in an internal table. While it may be convenient to declare an internal table using the LIKE command, in most cases, programs will not use all fields in the SAP standard table. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Instead of this: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: t_mara like mara occurs 0 with header line. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use this: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: begin of t_mara occurs 0, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;matnr like mara-matnr,&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;end of t_mara. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;8. Row-level processing and SELECT SINGLE &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Similar to the processing of a SELECT-ENDSELECT loop, when calling multiple SELECT-SINGLE commands on a non-buffered table (check Data Dictionary -&amp;gt; Technical Info), you should do the following to improve performance: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;o Use the SELECT into &amp;lt;itab&amp;gt; to buffer the necessary rows in an internal table, then&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;o sort the rows by the key fields, then &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;o use a READ TABLE WITH KEY ... BINARY SEARCH in place of the SELECT SINGLE command. Note that this only make sense when the table you are buffering is not too large (this decision must be made on a case by case basis).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;9. READing single records of internal tables&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When reading a single record in an internal table, the READ TABLE WITH KEY is not a direct READ. This means that if the data is not sorted according to the key, the system must sequentially read the table. Therefore, you should: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;o SORT the table&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;o use READ TABLE WITH KEY BINARY SEARCH for better performance. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;10. SORTing internal tables &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When SORTing internal tables, specify the fields to SORTed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SORT ITAB BY FLD1 FLD2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;is more efficient than&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SORT ITAB. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;11. Number of entries in an internal table &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To find out how many entries are in an internal table use DESCRIBE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DESCRIBE TABLE ITAB LINES CNTLNS.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;is more efficient than&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT ITAB.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CNTLNS = CNTLNS + 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDLOOP. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;12. Performance diagnosis &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To diagnose performance problems, it is recommended to use the SAP transaction SE30, ABAP/4 Runtime Analysis. The utility allows statistical analysis of transactions and programs. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;13. Nested SELECTs versus table views &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since releASE 4.0, OPEN SQL allows both inner and outer table joins. A nested SELECT loop may be used to accomplish the same concept. However, the performance of nested SELECT loops is very poor in comparison to a join. Hence, to improve performance by a factor of 25x and reduce network load, you should either create a view in the data dictionary then use this view to select data, or code the select using a join. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;14. If nested SELECTs must be used &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As mentioned previously, performance can be dramatically improved by using views instead of nested SELECTs, however, if this is not possible, then the following example of using an internal table in a nested SELECT can also improve performance by a factor of 5x:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use this:&lt;/P&gt;&lt;P&gt;form select_good.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: t_vbak like vbak occurs 0 with header line.&lt;/P&gt;&lt;P&gt;data: t_vbap like vbap occurs 0 with header line.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select * from vbak into table t_vbak up to 200 rows.&lt;/P&gt;&lt;P&gt;select * from vbap &lt;/P&gt;&lt;P&gt;for all entries in t_vbak&lt;/P&gt;&lt;P&gt;where vbeln = t_vbak-vbeln.&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;endselect.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endform.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Instead of this:&lt;/P&gt;&lt;P&gt;form select_bad.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select * from vbak up to 200 rows.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select * from vbap where vbeln = vbak-vbeln.&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;endselect.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endselect.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endform.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Although using "SELECT...FOR ALL ENTRIES IN..." is generally very fast, you should be aware of the three pitfalls of using it:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Firstly, SAP automatically removes any duplicates from the rest of the retrieved records. Therefore, if you wish to ensure that no qualifying records are discarded, the field list of the inner SELECT must be designed to ensure the retrieved records will contain no duplicates (normally, this would mean including in the list of retrieved fields all of those fields that comprise that table's primary key).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Secondly, if you were able to code "SELECT ... FROM &amp;lt;database table&amp;gt; FOR ALL ENTRIES IN TABLE &amp;lt;itab&amp;gt;" and the internal table &amp;lt;itab&amp;gt; is empty, then all rows from &amp;lt;database table&amp;gt; will be retrieved.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thirdly, if the internal table supplying the selection criteria (i.e. internal table &amp;lt;itab&amp;gt; in the example "...FOR ALL ENTRIES IN TABLE &amp;lt;itab&amp;gt; ") contains a large number of entries, performance degradation may occur. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;15. SELECT * versus SELECTing individual fields &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In general, use a SELECT statement specifying a list of fields instead of a SELECT * to reduce network traffic and improve performance. For tables with only a few fields the improvements may be minor, but many SAP tables contain more than 50 fields when the program needs only a few. In the latter case, the performace gains can be substantial. For example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select vbeln auart vbtyp from table vbak&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;into (vbak-vbeln, vbak-auart, vbak-vbtyp)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;where ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Instead of using:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select * from vbak where ... &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;16. Avoid unnecessary statements&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There are a few cases where one command is better than two. For example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;append &amp;lt;tab_wa&amp;gt; to &amp;lt;tab&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Instead of:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;tab&amp;gt; = &amp;lt;tab_wa&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;append &amp;lt;tab&amp;gt; (modify &amp;lt;tab&amp;gt;).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And also, use:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if not &amp;lt;tab&amp;gt;[] is initial.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Instead of:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;describe table &amp;lt;tab&amp;gt; lines &amp;lt;line_counter&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if &amp;lt;line_counter&amp;gt; &amp;gt; 0. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;17. Copying or appending internal tables&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use this: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;tab2&amp;gt;[] = &amp;lt;tab1&amp;gt;[]. (if &amp;lt;tab2&amp;gt; is empty)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Instead of this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at &amp;lt;tab1&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;append &amp;lt;tab1&amp;gt; to &amp;lt;tab2&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, if &amp;lt;tab2&amp;gt; is not empty and should not be overwritten, then use:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;append lines of &amp;lt;tab1&amp;gt; [from index1] [to index2] to &amp;lt;tab2&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;P.S : Please reward if you find this useful..&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 07 Mar 2007 09:25:54 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-03-07T09:25:54Z</dc:date>
    <item>
      <title>performance issues</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issues/m-p/1999095#M406776</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;what r the performance issues we have to do  while developing an object? could u plzz tell?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Mar 2007 08:27:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issues/m-p/1999095#M406776</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-03-07T08:27:40Z</dc:date>
    </item>
    <item>
      <title>Re: performance issues</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issues/m-p/1999096#M406777</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;  What kind of development object you want?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;        You need to basically see that you HIT the database very few times. Use the application server more to get your logic done, like using FOR ALL ENTRIES instead of JOIN etc.&lt;/P&gt;&lt;P&gt;      &lt;/P&gt;&lt;P&gt;        You pass the data by reference rather by VALUE for large internal tables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Sesh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Mar 2007 08:30:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issues/m-p/1999096#M406777</guid>
      <dc:creator>seshatalpasai_madala</dc:creator>
      <dc:date>2007-03-07T08:30:24Z</dc:date>
    </item>
    <item>
      <title>Re: performance issues</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issues/m-p/1999097#M406778</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Sonyia,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You prob need to use less of select * , and be more specific in your selection.&lt;/P&gt;&lt;P&gt;Using less internal table will result in better performance too.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;r3venant&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Mar 2007 08:36:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issues/m-p/1999097#M406778</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-03-07T08:36:02Z</dc:date>
    </item>
    <item>
      <title>Re: performance issues</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issues/m-p/1999098#M406779</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;check out this link: &lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sapbrain.com/ARTICLES/TECHNICAL/optimization/optimization.html" target="test_blank"&gt;http://www.sapbrain.com/ARTICLES/TECHNICAL/optimization/optimization.html&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Mar 2007 08:40:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issues/m-p/1999098#M406779</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-03-07T08:40:14Z</dc:date>
    </item>
    <item>
      <title>Re: performance issues</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issues/m-p/1999099#M406780</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;refer to this link:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://wiki.sdn.sap.com/wiki/display/HOME/ABAP" target="test_blank"&gt;https://wiki.sdn.sap.com/wiki/display/HOME/ABAP&lt;/A&gt;&lt;EM&gt;Performance&lt;/EM&gt;and+Tuning&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;madhumitha&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Mar 2007 08:53:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issues/m-p/1999099#M406780</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-03-07T08:53:16Z</dc:date>
    </item>
    <item>
      <title>Re: performance issues</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issues/m-p/1999100#M406781</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Go through the following Document&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Check the following Links&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sapgenie.com/abap/performance.htm" target="test_blank"&gt;http://www.sapgenie.com/abap/performance.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.thespot4sap.com/Articles/SAPABAPPerformanceTuning_PerformanceAnalysisTools.asp" target="test_blank"&gt;http://www.thespot4sap.com/Articles/SAPABAPPerformanceTuning_PerformanceAnalysisTools.asp&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;check the below link&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sap-img.com/abap/performance-tuning-for-data-selection-statement.htm" target="test_blank"&gt;http://www.sap-img.com/abap/performance-tuning-for-data-selection-statement.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;See the following link if it's any help:&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.thespot4sap.com/Articles/SAPABAPPerformanceTuning_PerformanceAnalysisTools.asp" target="test_blank"&gt;http://www.thespot4sap.com/Articles/SAPABAPPerformanceTuning_PerformanceAnalysisTools.asp&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Check also &lt;A href="http://service.sap.com/performance" target="test_blank"&gt;http://service.sap.com/performance&lt;/A&gt;&lt;/P&gt;&lt;P&gt;and &lt;/P&gt;&lt;P&gt;books like&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sap-press.com/product.cfm?account=&amp;amp;product=H951" target="test_blank"&gt;http://www.sap-press.com/product.cfm?account=&amp;amp;product=H951&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sap-press.com/product.cfm?account=&amp;amp;product=H973" target="test_blank"&gt;http://www.sap-press.com/product.cfm?account=&amp;amp;product=H973&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sap-img.com/abap/more-than-100-abap-interview-faqs.htm" target="test_blank"&gt;http://www.sap-img.com/abap/more-than-100-abap-interview-faqs.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For all entries&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Nested selects&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Select using JOINS&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use the selection criteria&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use the aggregated functions&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Select with view&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Select with index support&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Select &amp;#133; Into table&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Select with selection list&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Key access to multiple lines&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Copying internal tables&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Modifying a set of lines&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Deleting a sequence of lines&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Linear search vs. binary&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Comparison of internal tables&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Modify selected components&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Appending two internal tables&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Deleting a set of lines&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tools available in SAP to pin-point a performance problem&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Optimizing the load of the database&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For all entries&lt;/P&gt;&lt;P&gt;The for all entries creates a where clause, where all the entries in the driver table are combined with OR. If the number of entries in the driver table is larger than rsdb/max_blocking_factor, several similar SQL statements are executed to limit the length of the WHERE clause. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The plus &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Large amount of data &lt;/P&gt;&lt;P&gt;Mixing processing and reading of data &lt;/P&gt;&lt;P&gt;Fast internal reprocessing of data &lt;/P&gt;&lt;P&gt;Fast &lt;/P&gt;&lt;P&gt;The Minus &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Difficult to program/understand &lt;/P&gt;&lt;P&gt;Memory could be critical (use FREE or PACKAGE size) &lt;/P&gt;&lt;P&gt;Some steps that might make FOR ALL ENTRIES more efficient: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Removing duplicates from the driver table &lt;/P&gt;&lt;P&gt;Sorting the driver table &lt;/P&gt;&lt;P&gt;If possible, convert the data in the driver table to ranges so a BETWEEN statement is used instead of and OR statement: &lt;/P&gt;&lt;P&gt;FOR ALL ENTRIES IN i_tab&lt;/P&gt;&lt;P&gt;WHERE mykey &amp;gt;= i_tab-low and&lt;/P&gt;&lt;P&gt;mykey &amp;lt;= i_tab-high.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Nested selects&lt;/P&gt;&lt;P&gt;The plus: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Small amount of data &lt;/P&gt;&lt;P&gt;Mixing processing and reading of data &lt;/P&gt;&lt;P&gt;Easy to code - and understand &lt;/P&gt;&lt;P&gt;The minus: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Large amount of data &lt;/P&gt;&lt;P&gt;when mixed processing isn&amp;#146;t needed &lt;/P&gt;&lt;P&gt;Performance killer no. 1 &lt;/P&gt;&lt;P&gt;Select using JOINS&lt;/P&gt;&lt;P&gt;The plus &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Very large amount of data &lt;/P&gt;&lt;P&gt;Similar to Nested selects - when the accesses are planned by the programmer &lt;/P&gt;&lt;P&gt;In some cases the fastest &lt;/P&gt;&lt;P&gt;Not so memory critical &lt;/P&gt;&lt;P&gt;The minus &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Very difficult to program/understand &lt;/P&gt;&lt;P&gt;Mixing processing and reading of data not possible &lt;/P&gt;&lt;P&gt;Use the selection criteria&lt;/P&gt;&lt;P&gt;SELECT * FROM SBOOK. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CHECK: SBOOK-CARRID = 'LH' AND &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SBOOK-CONNID = '0400'. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDSELECT. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT * FROM SBOOK &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;WHERE CARRID = 'LH' AND &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CONNID = '0400'. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDSELECT. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use the aggregated functions&lt;/P&gt;&lt;P&gt;C4A = '000'. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT * FROM T100 &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;WHERE SPRSL = 'D' AND &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ARBGB = '00'. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CHECK: T100-MSGNR &amp;gt; C4A. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;C4A = T100-MSGNR. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDSELECT. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT MAX( MSGNR ) FROM T100 INTO C4A &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;WHERE SPRSL = 'D' AND &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ARBGB = '00'. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Select with view&lt;/P&gt;&lt;P&gt;SELECT * FROM DD01L &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;WHERE DOMNAME LIKE 'CHAR%' &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;AND AS4LOCAL = 'A'. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT SINGLE * FROM DD01T &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;WHERE DOMNAME = DD01L-DOMNAME &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;AND AS4LOCAL = 'A' &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;AND AS4VERS = DD01L-AS4VERS &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;AND DDLANGUAGE = SY-LANGU. &lt;/P&gt;&lt;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GB = '00' &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;AND MSGNR = '999'. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDSELECT. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDSELECT. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Select &amp;#133; Into table&lt;/P&gt;&lt;P&gt;REFRESH X006. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT * FROM T006 INTO X006. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;APPEND X006. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDSELECT&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT * FROM T006 INTO TABLE X006.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Select with selection list&lt;/P&gt;&lt;P&gt;SELECT * FROM DD01L &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;WHERE DOMNAME LIKE 'CHAR%' &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;AND AS4LOCAL = 'A'. &lt;/P&gt;&lt;P&gt;&lt;/P&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&lt;P&gt;TAB-FLAG = 'X'. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MODIFY TAB TRANSPORTING FLAG &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;WHERE FLAG IS INITIAL. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Deleting a sequence of lines&lt;/P&gt;&lt;P&gt;DO 101 TIMES. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DELETE TAB_DEST INDEX 450. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDDO. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DELETE TAB_DEST FROM 450 TO 550.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Linear search vs. binary&lt;/P&gt;&lt;P&gt;READ TABLE TAB WITH KEY K = 'X'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;READ TABLE TAB WITH KEY K = 'X' BINARY SEARCH.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Comparison of internal tables&lt;/P&gt;&lt;P&gt;DESCRIBE TABLE: TAB1 LINES L1, &lt;/P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;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDLOOP. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Appending two internal tables&lt;/P&gt;&lt;P&gt;LOOP AT TAB_SRC. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;APPEND TAB_SRC TO TAB_DEST. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDLOOP&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;APPEND LINES OF TAB_SRC TO TAB_DEST.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Deleting a set of lines&lt;/P&gt;&lt;P&gt;LOOP AT TAB_DEST WHERE K = KVAL. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DELETE TAB_DEST. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDLOOP&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DELETE TAB_DEST WHERE K = KVAL.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tools available in SAP to pin-point a performance problem&lt;/P&gt;&lt;P&gt;· The runtime analysis (SE30)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;· SQL Trace (ST05)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;· Tips and Tricks tool &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;· The performance database&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Optimizing the load of the database&lt;/P&gt;&lt;P&gt;Using table buffering&lt;/P&gt;&lt;P&gt;Using buffered tables improves the performance considerably. Note that in some cases a statement can not be used with a buffered table, so when using these statements the buffer will be bypassed. These statements are: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Select DISTINCT &lt;/P&gt;&lt;P&gt;ORDER BY / GROUP BY / HAVING clause &lt;/P&gt;&lt;P&gt;Any WHERE clause that contains a sub query or IS NULL expression &lt;/P&gt;&lt;P&gt;JOIN s &lt;/P&gt;&lt;P&gt;A SELECT... FOR UPDATE &lt;/P&gt;&lt;P&gt;If you wan t to explicitly bypass the buffer, use the BYPASS BUFFER addition to the SELECT clause. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use the ABAP SORT Clause Instead of ORDER BY&lt;/P&gt;&lt;P&gt;The ORDER BY clause is executed on the database server while the ABAP SORT statement is executed on the application server. The database server will usually be the bottleneck, so sometimes it is better to move the sort from the database server to the application server. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you are not sorting by the primary key ( E.g. using the ORDER BY PRIMARY key statement) but are sorting by another key, it could be better to use the ABAP SORT statement to sort the data in an internal table. Note however that for very large result sets it might not be a feasible solution and you would want to let the database server sort it. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Avoid the SELECT DISTINCT Statement&lt;/P&gt;&lt;P&gt;As with the ORDER BY clause it could be better to avoid using SELECT DISTINCT, if some of the fields are not part of an index. Instead use ABAP SORT + DELETE ADJACENT DUPLICATES on an internal table, to delete duplicate rows. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kishore&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Mar 2007 08:56:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issues/m-p/1999100#M406781</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-03-07T08:56:07Z</dc:date>
    </item>
    <item>
      <title>Re: performance issues</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issues/m-p/1999101#M406782</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For performance tuning steps,you can try transaction ST05 for SQL Performance trace.For ABAP runtime anaysis,try se30.You can execute your program and then check the DB and ABAP access which is greatly beneficial for performance tuning.Further, check "tips and tricks" in se30.You can find some efficient ways of coding.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Beejal&lt;/P&gt;&lt;P&gt;**Reward if answer is helpful&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Mar 2007 09:10:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issues/m-p/1999101#M406782</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-03-07T09:10:15Z</dc:date>
    </item>
    <item>
      <title>Re: performance issues</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issues/m-p/1999102#M406783</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;1. Unused/Dead code &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Avoid leaving unused code in the program. Either comment out or delete the unused situation. Use program --&amp;gt; check --&amp;gt; extended program to check for the variables, which are not used statically. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. Subroutine Usage &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For good modularization, the decision of whether or not to execute a subroutine should be made before the subroutine is called. For example: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is better:&lt;/P&gt;&lt;P&gt;IF f1 NE 0. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PERFORM sub1. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDIF. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FORM sub1.&lt;/P&gt;&lt;P&gt;... &lt;/P&gt;&lt;P&gt;ENDFORM. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Than this: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PERFORM sub1. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FORM sub1.&lt;/P&gt;&lt;P&gt;IF f1 NE 0.&lt;/P&gt;&lt;P&gt;... &lt;/P&gt;&lt;P&gt;ENDIF. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDFORM. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3. Usage of IF statements &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When coding IF tests, nest the testing conditions so that the outer conditions are those which are most likely to fail. For logical expressions with AND , place the mostly likely false first and for the OR, place the mostly likely true first. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example - nested IF's: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF (least likely to be true). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF (less likely to be true). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF (most likely to be true).&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;ENDIF. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example - IF...ELSEIF...ENDIF : &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF (most likely to be true). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ELSEIF (less likely to be true). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ELSEIF (least likely to be true). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDIF. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example - AND: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF (least likely to be true) AND &lt;/P&gt;&lt;P&gt;(most likely to be true). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDIF. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example - OR: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF (most likely to be true) OR&lt;/P&gt;&lt;P&gt;(least likely to be true). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;4. CASE vs. nested Ifs&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When testing fields "equal to" something, one can use either the nested IF or the CASE statement. The CASE is better for two reasons. It is easier to read and after about five nested IFs the performance of the CASE is more efficient. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;5. MOVE statements &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When records a and b have the exact same structure, it is more efficient to MOVE a TO b than to MOVE-CORRESPONDING a TO b. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MOVE BSEG TO *BSEG. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;is better than &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MOVE-CORRESPONDING BSEG TO *BSEG. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;6. SELECT and SELECT SINGLE &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When using the SELECT statement, study the key and always provide as much of the left-most part of the key as possible. If the entire key can be qualified, code a SELECT SINGLE not just a SELECT. If you are only interested in the first row or there is only one row to be returned, using SELECT SINGLE can increase performance by up to three times. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;7. Small internal tables vs. complete internal tables &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In general it is better to minimize the number of fields declared in an internal table. While it may be convenient to declare an internal table using the LIKE command, in most cases, programs will not use all fields in the SAP standard table. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Instead of this: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: t_mara like mara occurs 0 with header line. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use this: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: begin of t_mara occurs 0, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;matnr like mara-matnr,&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;end of t_mara. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;8. Row-level processing and SELECT SINGLE &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Similar to the processing of a SELECT-ENDSELECT loop, when calling multiple SELECT-SINGLE commands on a non-buffered table (check Data Dictionary -&amp;gt; Technical Info), you should do the following to improve performance: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;o Use the SELECT into &amp;lt;itab&amp;gt; to buffer the necessary rows in an internal table, then&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;o sort the rows by the key fields, then &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;o use a READ TABLE WITH KEY ... BINARY SEARCH in place of the SELECT SINGLE command. Note that this only make sense when the table you are buffering is not too large (this decision must be made on a case by case basis).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;9. READing single records of internal tables&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When reading a single record in an internal table, the READ TABLE WITH KEY is not a direct READ. This means that if the data is not sorted according to the key, the system must sequentially read the table. Therefore, you should: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;o SORT the table&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;o use READ TABLE WITH KEY BINARY SEARCH for better performance. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;10. SORTing internal tables &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When SORTing internal tables, specify the fields to SORTed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SORT ITAB BY FLD1 FLD2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;is more efficient than&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SORT ITAB. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;11. Number of entries in an internal table &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To find out how many entries are in an internal table use DESCRIBE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DESCRIBE TABLE ITAB LINES CNTLNS.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;is more efficient than&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT ITAB.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CNTLNS = CNTLNS + 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDLOOP. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;12. Performance diagnosis &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To diagnose performance problems, it is recommended to use the SAP transaction SE30, ABAP/4 Runtime Analysis. The utility allows statistical analysis of transactions and programs. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;13. Nested SELECTs versus table views &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since releASE 4.0, OPEN SQL allows both inner and outer table joins. A nested SELECT loop may be used to accomplish the same concept. However, the performance of nested SELECT loops is very poor in comparison to a join. Hence, to improve performance by a factor of 25x and reduce network load, you should either create a view in the data dictionary then use this view to select data, or code the select using a join. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;14. If nested SELECTs must be used &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As mentioned previously, performance can be dramatically improved by using views instead of nested SELECTs, however, if this is not possible, then the following example of using an internal table in a nested SELECT can also improve performance by a factor of 5x:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use this:&lt;/P&gt;&lt;P&gt;form select_good.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: t_vbak like vbak occurs 0 with header line.&lt;/P&gt;&lt;P&gt;data: t_vbap like vbap occurs 0 with header line.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select * from vbak into table t_vbak up to 200 rows.&lt;/P&gt;&lt;P&gt;select * from vbap &lt;/P&gt;&lt;P&gt;for all entries in t_vbak&lt;/P&gt;&lt;P&gt;where vbeln = t_vbak-vbeln.&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;endselect.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endform.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Instead of this:&lt;/P&gt;&lt;P&gt;form select_bad.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select * from vbak up to 200 rows.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select * from vbap where vbeln = vbak-vbeln.&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;endselect.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endselect.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endform.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Although using "SELECT...FOR ALL ENTRIES IN..." is generally very fast, you should be aware of the three pitfalls of using it:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Firstly, SAP automatically removes any duplicates from the rest of the retrieved records. Therefore, if you wish to ensure that no qualifying records are discarded, the field list of the inner SELECT must be designed to ensure the retrieved records will contain no duplicates (normally, this would mean including in the list of retrieved fields all of those fields that comprise that table's primary key).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Secondly, if you were able to code "SELECT ... FROM &amp;lt;database table&amp;gt; FOR ALL ENTRIES IN TABLE &amp;lt;itab&amp;gt;" and the internal table &amp;lt;itab&amp;gt; is empty, then all rows from &amp;lt;database table&amp;gt; will be retrieved.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thirdly, if the internal table supplying the selection criteria (i.e. internal table &amp;lt;itab&amp;gt; in the example "...FOR ALL ENTRIES IN TABLE &amp;lt;itab&amp;gt; ") contains a large number of entries, performance degradation may occur. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;15. SELECT * versus SELECTing individual fields &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In general, use a SELECT statement specifying a list of fields instead of a SELECT * to reduce network traffic and improve performance. For tables with only a few fields the improvements may be minor, but many SAP tables contain more than 50 fields when the program needs only a few. In the latter case, the performace gains can be substantial. For example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select vbeln auart vbtyp from table vbak&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;into (vbak-vbeln, vbak-auart, vbak-vbtyp)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;where ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Instead of using:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select * from vbak where ... &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;16. Avoid unnecessary statements&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There are a few cases where one command is better than two. For example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;append &amp;lt;tab_wa&amp;gt; to &amp;lt;tab&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Instead of:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;tab&amp;gt; = &amp;lt;tab_wa&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;append &amp;lt;tab&amp;gt; (modify &amp;lt;tab&amp;gt;).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And also, use:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if not &amp;lt;tab&amp;gt;[] is initial.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Instead of:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;describe table &amp;lt;tab&amp;gt; lines &amp;lt;line_counter&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if &amp;lt;line_counter&amp;gt; &amp;gt; 0. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;17. Copying or appending internal tables&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use this: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;tab2&amp;gt;[] = &amp;lt;tab1&amp;gt;[]. (if &amp;lt;tab2&amp;gt; is empty)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Instead of this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at &amp;lt;tab1&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;append &amp;lt;tab1&amp;gt; to &amp;lt;tab2&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, if &amp;lt;tab2&amp;gt; is not empty and should not be overwritten, then use:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;append lines of &amp;lt;tab1&amp;gt; [from index1] [to index2] to &amp;lt;tab2&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;P.S : Please reward if you find this useful..&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Mar 2007 09:25:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-issues/m-p/1999102#M406783</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-03-07T09:25:54Z</dc:date>
    </item>
  </channel>
</rss>

