<?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: ABAP Code performance in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-code-performance/m-p/1655253#M290838</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Go into transaction st05, activate trace, run your program, go back to st05 and deactivate and display. Go to trace list -&amp;gt; summarize by table or combined table accesses then table list aggregate and post the results.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also run se30 to check for inefficient code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As most peiple have already mentioned select  for all entries then read is probably the way to go. Please consider using auxiliary tables to do your selections if the data is repeated particularly if your material is repeated often e.g. &lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;define auxiliary table for your internal table same type and fill with entries from your existing internal table &lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;i_t_data_aux[] = i_t_data[].&lt;/P&gt;&lt;P&gt;Sort i_t_data_aux by werks.&lt;/P&gt;&lt;P&gt;delete adjacent duplicates from i_t_data_aux[] comparing werks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select bukrs &lt;/P&gt;&lt;P&gt;from t001k&lt;/P&gt;&lt;P&gt;for all entries in i_t_data_aux[].&lt;/P&gt;&lt;P&gt;where T001K~BWKEY = I_T_DATA_aux-WERKS.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 13 Dec 2006 16:11:46 GMT</pubDate>
    <dc:creator>alison_lloyd</dc:creator>
    <dc:date>2006-12-13T16:11:46Z</dc:date>
    <item>
      <title>ABAP Code performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-code-performance/m-p/1655228#M290813</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Guys,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The following code seems to be taking considerable time in production. Is there a better way to optimize theis code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT I_T_DATA...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    SELECT SINGLE BUKRS&lt;/P&gt;&lt;P&gt;     INTO (l_bukrs)&lt;/P&gt;&lt;P&gt;     FROM T001K&lt;/P&gt;&lt;P&gt;     WHERE T001K~BWKEY = I_T_DATA-WERKS.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    SELECT SINGLE TARGET1 TARGET2&lt;/P&gt;&lt;P&gt;    INTO (l_salesorg, l_dischan)&lt;/P&gt;&lt;P&gt;    from ZDERIV&lt;/P&gt;&lt;P&gt;    where VALID_FROM le sy-datum&lt;/P&gt;&lt;P&gt;      and SOUR3_FROM le I_T_DATA-prctr&lt;/P&gt;&lt;P&gt;      and SOUR3_TO ge I_T_DATA-prctr&lt;/P&gt;&lt;P&gt;      and SOUR2_FROM le l_bukrs&lt;/P&gt;&lt;P&gt;      and SOUR2_TO ge l_bukrs&lt;/P&gt;&lt;P&gt;      and SOUR1_FROM = 'C100'&lt;/P&gt;&lt;P&gt;      and SOUR1_TO = 'C100'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    CASE sy-subrc.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;     when 0.&lt;/P&gt;&lt;P&gt;       SELECT SINGLE PRODH&lt;/P&gt;&lt;P&gt;       INTO I_T_DATA-zzPRODH&lt;/P&gt;&lt;P&gt;       from mvke&lt;/P&gt;&lt;P&gt;       where matnr eq I_T_DATA-matnr&lt;/P&gt;&lt;P&gt;       and vkorg eq l_salesorg&lt;/P&gt;&lt;P&gt;       and vtweg eq l_dischan.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;     WHEN 4.&lt;/P&gt;&lt;P&gt;       Clear: l_salesorg, l_dischan.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    ENDCASE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Nov 2006 14:36:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-code-performance/m-p/1655228#M290813</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-08T14:36:06Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP Code performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-code-performance/m-p/1655229#M290814</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;how many records are there in i_t_data..&lt;/P&gt;&lt;P&gt;my feeling is get all the records into the internal table first and then in the loop process the records. use read table command to read ur internal tables&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;santhosh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Nov 2006 14:41:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-code-performance/m-p/1655229#M290814</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-08T14:41:09Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP Code performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-code-performance/m-p/1655230#M290815</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I would imagine that the time being spent on this select statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

SELECT SINGLE TARGET1 TARGET2
INTO (l_salesorg, l_dischan)
from ZDERIV
where VALID_FROM le sy-datum
  and SOUR3_FROM le I_T_DATA-prctr
  and SOUR3_TO ge I_T_DATA-prctr
  and SOUR2_FROM le l_bukrs
  and SOUR2_TO ge l_bukrs
  and SOUR1_FROM = 'C100'
  and SOUR1_TO = 'C100'.
  

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can you please verify that the fields in your WHERE clause are in the same order as they are in the table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Rich Heilman&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Nov 2006 14:43:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-code-performance/m-p/1655230#M290815</guid>
      <dc:creator>RichHeilman</dc:creator>
      <dc:date>2006-11-08T14:43:05Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP Code performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-code-performance/m-p/1655231#M290816</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi santosh,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There are nearly half-a-million records.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Nov 2006 14:45:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-code-performance/m-p/1655231#M290816</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-08T14:45:12Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP Code performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-code-performance/m-p/1655232#M290817</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Rich,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;They are not in the same order. In the table their order is,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SOUR1_FROM&lt;/P&gt;&lt;P&gt;SOUR1_TO&lt;/P&gt;&lt;P&gt;SOUR2_FROM&lt;/P&gt;&lt;P&gt;SOUR2_TO&lt;/P&gt;&lt;P&gt;SOUR3_FROM&lt;/P&gt;&lt;P&gt;SOUR3_TO&lt;/P&gt;&lt;P&gt;VALID_FROM&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I was not aware that the sequence of the fields does matter.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Nov 2006 14:49:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-code-performance/m-p/1655232#M290817</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-08T14:49:04Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP Code performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-code-performance/m-p/1655233#M290818</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It does matter, very much  Please recontruct your WHERE clause in such a way that the order is the same as the key fields of table database table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Rich Heilman&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Nov 2006 14:53:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-code-performance/m-p/1655233#M290818</guid>
      <dc:creator>RichHeilman</dc:creator>
      <dc:date>2006-11-08T14:53:34Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP Code performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-code-performance/m-p/1655234#M290819</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Sachin,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regarding the query on the Z-table:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. Is there an index present on the fields given in the where clause. If there is no index and if this kind of query is always used you can consider creating one.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. Are there more than one fields in the where clause that correspond to different indexes. Then you might have to force the usage of one index by '%_hints' command or by adding more fields in the where clause and passing some default values or ranges.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3. If you can paste the execution plan of the query as in ST05, it will be helpful.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Sameer&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Nov 2006 14:54:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-code-performance/m-p/1655234#M290819</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-08T14:54:01Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP Code performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-code-performance/m-p/1655235#M290820</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is how my new code looks:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT I_T_DATA...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT SINGLE BUKRS&lt;/P&gt;&lt;P&gt;INTO (l_bukrs)&lt;/P&gt;&lt;P&gt;FROM T001K&lt;/P&gt;&lt;P&gt;WHERE T001K~BWKEY = I_T_DATA-WERKS.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CASE sy-subrc.&lt;/P&gt;&lt;P&gt;     WHEN 0.&lt;/P&gt;&lt;P&gt;     WHEN 4.&lt;/P&gt;&lt;P&gt;        CLEAR: l_bukrs.&lt;/P&gt;&lt;P&gt;    ENDCASE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT SINGLE TARGET1 TARGET2&lt;/P&gt;&lt;P&gt;    INTO (l_salesorg, l_dischan)&lt;/P&gt;&lt;P&gt;    from ZDERIV&lt;/P&gt;&lt;P&gt;    where SOUR1_FROM = 'C100'&lt;/P&gt;&lt;P&gt;      and SOUR1_TO = 'C100'&lt;/P&gt;&lt;P&gt;      and SOUR2_FROM le l_bukrs&lt;/P&gt;&lt;P&gt;      and SOUR2_TO ge l_bukrs&lt;/P&gt;&lt;P&gt;      and SOUR3_FROM le I_T_DATA-prctr&lt;/P&gt;&lt;P&gt;      and SOUR3_TO ge I_T_DATA-prctr&lt;/P&gt;&lt;P&gt;      and VALID_FROM le sy-datum.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    CASE sy-subrc.&lt;/P&gt;&lt;P&gt;     WHEN 0.&lt;/P&gt;&lt;P&gt;       SELECT SINGLE PRODH&lt;/P&gt;&lt;P&gt;       INTO I_T_DATA-zzPRODH&lt;/P&gt;&lt;P&gt;       from mvke&lt;/P&gt;&lt;P&gt;       where matnr eq I_T_DATA-matnr&lt;/P&gt;&lt;P&gt;       and vkorg eq l_salesorg&lt;/P&gt;&lt;P&gt;       and vtweg eq l_dischan.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;     WHEN 4.&lt;/P&gt;&lt;P&gt;       Clear: l_salesorg, l_dischan.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    ENDCASE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can this be optimized further. If not, how do we check to see if this improved the performance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Where to check for field indexes?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Nov 2006 15:44:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-code-performance/m-p/1655235#M290820</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-08T15:44:53Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP Code performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-code-performance/m-p/1655236#M290821</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;We need to see the indexes on table ZDERIV. could you post them please?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It may be better to use FOR ALL ENTRIES on I_T_DATA rather than looping through it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If not, you can definitely move the select on T001K outside of the loop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Nov 2006 15:54:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-code-performance/m-p/1655236#M290821</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-08T15:54:47Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP Code performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-code-performance/m-p/1655237#M290822</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I don't know what platform he's on, but if it is Oracle, the predicate order doesn't matter.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It used to matter under older versions of Oracle, under the Rule-based optimizer.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Assuming he's using the Cost-based optimizer, which he should be, as long as he's specified all the keys, or at least the leading part, he'll fully or partially use the index.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Nov 2006 16:00:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-code-performance/m-p/1655237#M290822</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-08T16:00:52Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP Code performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-code-performance/m-p/1655238#M290823</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Guys,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your guidance. We are on Oracle 9.2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob, when I clicked on 'Indexes' button for ZDERIV table, i got a message saying - No index has been defined for table ZDERIV. Do you want to create an Index?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could you give more details as to how to optimize the code?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Nov 2006 16:11:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-code-performance/m-p/1655238#M290823</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-08T16:11:56Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP Code performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-code-performance/m-p/1655239#M290824</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;OK - what are the primary keys of the table (in order)?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Nov 2006 16:22:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-code-performance/m-p/1655239#M290824</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-08T16:22:04Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP Code performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-code-performance/m-p/1655240#M290825</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Rob,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;These are the keys of the table in the order:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MANDT&lt;/P&gt;&lt;P&gt;SOUR1_FROM&lt;/P&gt;&lt;P&gt;SOUR1_TO&lt;/P&gt;&lt;P&gt;SOUR2_FROM&lt;/P&gt;&lt;P&gt;SOUR2_TO&lt;/P&gt;&lt;P&gt;SOUR3_FROM&lt;/P&gt;&lt;P&gt;SOUR3_TO&lt;/P&gt;&lt;P&gt;VALID_FROM&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Ram&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Nov 2006 16:29:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-code-performance/m-p/1655240#M290825</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-08T16:29:38Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP Code performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-code-performance/m-p/1655241#M290826</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;See if this is faster:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT SINGLE target1 target2
  INTO (l_salesorg, l_dischan)
  FROM zderiv
  FOR ALL ENTRIES IN i_t_data
  WHERE sour1_from = 'C100'
    AND sour1_to   = 'C100'
    AND sour2_from LE i_t_data-werks
    AND sour2_to   GE i_t_data-werks
    AND sour3_from LE i_t_data-prctr
    AND sour3_to   GE i_t_data-prctr
    AND valid_from LE sy-datum.

CASE sy-subrc.
  WHEN 0.
    SELECT SINGLE prodh
    INTO i_t_data-zzprodh
    FROM mvke
   WHERE matnr EQ i_t_data-matnr
    AND vkorg EQ l_salesorg
    AND vtweg EQ l_dischan.

  WHEN 4.
    CLEAR: l_salesorg, l_dischan.

ENDCASE.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I wasn't able to test this because of the custom tables, so you must test it thoroughly.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The order of the fields in the SELECT may or may not make a difference. But I always find it good programming practice to put them in the where clause in the same order as they are in the table; however, if I'm trying to use a secondary index, I put them in that order. This makes it much easier for subsequent programmers to read.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Nov 2006 17:07:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-code-performance/m-p/1655241#M290826</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-08T17:07:46Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP Code performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-code-performance/m-p/1655242#M290827</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Rob,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I got an error:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The addition "FOR ALL ENTRIES" is not allowed for SELECT SINGLE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Nov 2006 17:53:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-code-performance/m-p/1655242#M290827</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-08T17:53:48Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP Code performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-code-performance/m-p/1655243#M290828</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You'll have to take the SINGLE out of the SELECT and create an internal table for the results.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA: BEGIN OF itab OCCURS 0,
        l_salesorg LIKE zderiv-target1,
        l_dischan  LIKE zderiv-target2,
      END   OF itab.

SELECT target1 target2
  INTO TABLE itab
  FROM zderiv
  FOR ALL ENTRIES IN i_t_data
  WHERE sour1_from = 'C100'
    AND sour1_to   = 'C100'
    AND sour2_from LE i_t_data-werks
    AND sour2_to   GE i_t_data-werks
    AND sour3_from LE i_t_data-prctr
    AND sour3_to   GE i_t_data-prctr
    AND valid_from LE sy-datum.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The logic will also change for the select from MVKE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: Rob Burbank&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Nov 2006 18:07:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-code-performance/m-p/1655243#M290828</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-08T18:07:19Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP Code performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-code-performance/m-p/1655244#M290829</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Rob,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am planning to use 'Field-Symbols' instead of I_T_DATA since it gives a better performance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT I_T_DATA ASSIGNING &amp;lt;FS&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When i used &amp;lt;FS&amp;gt; with FOR ALL ENTRIES in the SELECT statement, i get an error. Can't we use 'FOR ALL ENTRIES' with &amp;lt;FS&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT TARGET1 TARGET2&lt;/P&gt;&lt;P&gt;    INTO TABLE target&lt;/P&gt;&lt;P&gt;    FROM ZDERIV&lt;/P&gt;&lt;P&gt;    FOR ALL ENTRIES IN &amp;lt;FS&amp;gt;&lt;/P&gt;&lt;P&gt;    where SOUR1_FROM = 'C100'&lt;/P&gt;&lt;P&gt;      and SOUR1_TO = 'C100'&lt;/P&gt;&lt;P&gt;      and SOUR2_FROM le l_bukrs&lt;/P&gt;&lt;P&gt;      and SOUR2_TO ge l_bukrs&lt;/P&gt;&lt;P&gt;      and SOUR3_FROM le &amp;lt;FS&amp;gt;-prctr&lt;/P&gt;&lt;P&gt;      and SOUR3_TO ge &amp;lt;FS&amp;gt;-prctr&lt;/P&gt;&lt;P&gt;      and VALID_FROM le sy-datum.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This code didn't work. Thanks for your patience and help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Nov 2006 18:39:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-code-performance/m-p/1655244#M290829</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-08T18:39:18Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP Code performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-code-performance/m-p/1655245#M290830</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Sachin,&lt;/P&gt;&lt;P&gt;you can use a field-symbols which of course must be type as table. But with the specifc statement the field-symbol wont improve the performance.&lt;/P&gt;&lt;P&gt;Field-Symbols help when looping over the table avoiding the necessity to copy each record into a (header) line. But for operations on the table content itself they are of no great use.&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;  Klaus&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Nov 2006 18:45:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-code-performance/m-p/1655245#M290830</guid>
      <dc:creator>former_member183804</dc:creator>
      <dc:date>2006-11-08T18:45:54Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP Code performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-code-performance/m-p/1655246#M290831</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Using field symbols might give a small increase in performance, but the best way for you to acheive what you want is to reduce the number of trips to the database. FOR ALL ENTRIES or database joins are still your best bet.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Nov 2006 18:46:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-code-performance/m-p/1655246#M290831</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-08T18:46:02Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP Code performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-code-performance/m-p/1655247#M290832</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sachin,&lt;/P&gt;&lt;P&gt;If possible avoid the select statements inside the loop. You can select the data before the loop and store in some internal table. Inside the loop use read statement (with binary search) two read the record (can use Hash Table also).&lt;/P&gt;&lt;P&gt;Please mark the thread answered if yiu already have the solution.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Nov 2006 11:06:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-code-performance/m-p/1655247#M290832</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-24T11:06:36Z</dc:date>
    </item>
  </channel>
</rss>

