<?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: Avoid max selection in loop in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/avoid-max-selection-in-loop/m-p/6473939#M1417761</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Siegfried Boes ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; got information from basis that due to my program there were many deadlocks&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;is it necessary to use &lt;STRONG&gt;commit&lt;/STRONG&gt; statement over there&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please look into the code&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Read all records in active table of ODS into itab_ord&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;select * from /BIC/AZVFOSDP200&lt;/P&gt;&lt;P&gt;appending corresponding fields of table itab_ord&lt;/P&gt;&lt;P&gt;where /BIC/ZPVIEWDT &amp;gt; '19900101'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;commit.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Insert Changes&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;loop at itab_omod where SID eq ' '.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;itab_omod-sid = zarequest.&lt;/P&gt;&lt;P&gt;itab_omod-datapakid = zadatapakid.&lt;/P&gt;&lt;P&gt;itab_omod-record = zarecord.&lt;/P&gt;&lt;P&gt;modify itab_omod.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;zarecord = zarecord + 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;insert into /BIC/AZVFOSDP240 values itab_omod.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;commit.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Changing the contents of new table with the value&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;MODIFY /BIC/AZVFOSDP240 from table itab_neword.&lt;/P&gt;&lt;P&gt;commit&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Path&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 07 Jan 2010 15:23:13 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2010-01-07T15:23:13Z</dc:date>
    <item>
      <title>Avoid max selection in loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/avoid-max-selection-in-loop/m-p/6473923#M1417745</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;I searched in this forum but coudnt able to figure out a one for my problem&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can anyone let me know how to change this code to make it performance wise efficient&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I added the selecting max value inside loop becuse &lt;/P&gt;&lt;P&gt;i want to select max value for the given sales order,sales item and schedule line.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;please look into the code&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at itab_newcon .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select  max( /bic/zpviewdt ) from /bic/azvfosp1w00 into variable_ord&lt;/P&gt;&lt;P&gt;  where&lt;/P&gt;&lt;P&gt; doc_number = itab_newcon-doc_number and&lt;/P&gt;&lt;P&gt;  s_ord_item = itab_newcon-s_ord_item and&lt;/P&gt;&lt;P&gt;  sched_line = itab_newcon-sched_line.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; wa_pdate-DOC_NUMBER = itab_newcon-DOC_NUMBER.&lt;/P&gt;&lt;P&gt; wa_pdate-S_ORD_ITEM = itab_newcon-S_ORD_ITEM.&lt;/P&gt;&lt;P&gt; wa_pdate-sched_line = itab_newcon-SCHED_LINE.&lt;/P&gt;&lt;P&gt; wa_pdate-pdate = variable_ord.&lt;/P&gt;&lt;P&gt; APPEND wa_pdate to it_pdate.&lt;/P&gt;&lt;P&gt; clear variable_ord.&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;Regards&lt;/P&gt;&lt;P&gt;Path&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Jan 2010 12:39:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/avoid-max-selection-in-loop/m-p/6473923#M1417745</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-01-07T12:39:07Z</dc:date>
    </item>
    <item>
      <title>Re: Avoid max selection in loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/avoid-max-selection-in-loop/m-p/6473924#M1417746</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can avoid the select in loop,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;by selecting the data from the table related with itab_newcon to a internal table using for all entries of itab_newcon and then filtering the max values.&lt;/P&gt;&lt;P&gt;by using a join statement between /bic/azvfosp1w00 and the table relted with itab_newcon along with max function together&lt;/P&gt;&lt;P&gt;or by creating a view for /bic/azvfosp1w00 and the table related to itab_newcon ,then selecting the data using max function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then use a read statement in the loop.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Jan 2010 13:07:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/avoid-max-selection-in-loop/m-p/6473924#M1417746</guid>
      <dc:creator>kesavadas_thekkillath</dc:creator>
      <dc:date>2010-01-07T13:07:52Z</dc:date>
    </item>
    <item>
      <title>Re: Avoid max selection in loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/avoid-max-selection-in-loop/m-p/6473925#M1417747</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi. should be something like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT doc_number, s_ord_item, sched_line, max( /bic/zpviewdt ) 
FROM   /bic/azvfosp1w00 
INTO   TABLE it_pdate
FOR    ALL ENTRIES IN itab_newcon 
WHERE  doc_number = itab_newcon-doc_number
AND    s_ord_item = itab_newcon-s_ord_item
AND    sched_line = itab_newcon-sched_line
GROUP  BY doc_number, s_ord_item, sched_line.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;depending on how itab_newcon was populated you might be able to avoid FOR ALL ENTRIES, but you haven't showed us that part of the code.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Jan 2010 13:10:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/avoid-max-selection-in-loop/m-p/6473925#M1417747</guid>
      <dc:creator>Rui_Dantas</dc:creator>
      <dc:date>2010-01-07T13:10:28Z</dc:date>
    </item>
    <item>
      <title>Re: Avoid max selection in loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/avoid-max-selection-in-loop/m-p/6473926#M1417748</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi Rui Pedro Dantas ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For all entries with aggregate function is not possible.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Jan 2010 13:11:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/avoid-max-selection-in-loop/m-p/6473926#M1417748</guid>
      <dc:creator>kesavadas_thekkillath</dc:creator>
      <dc:date>2010-01-07T13:11:23Z</dc:date>
    </item>
    <item>
      <title>Re: Avoid max selection in loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/avoid-max-selection-in-loop/m-p/6473927#M1417749</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;gt; by selecting the data to a internal table using for all entries and then filtering the max values.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;No, you can't combine a FAE with an aggregate function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And I can not generally be recommended to SELECT everything instead of use an aggregate function. The aggregate can dramatically reduce the number of transferred records. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, if the internal table  itab_newcon comes from a previous selection, then a join could be an option.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How many line are in the internal table?&lt;/P&gt;&lt;P&gt;How many records are in average related to one maximum line?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Siegfried&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Jan 2010 13:15:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/avoid-max-selection-in-loop/m-p/6473927#M1417749</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-01-07T13:15:06Z</dc:date>
    </item>
    <item>
      <title>Re: Avoid max selection in loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/avoid-max-selection-in-loop/m-p/6473928#M1417750</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;As you rightly expected, the performace is affected because of the select query inside the loop. You may try something like this to avoid the select inside the loop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

"Declare a internal table with the fields /bic/zpviewdt , 
" docno, s_ord_item, sched_line say itab

select  /bic/zpviewdt docno s_ord_itam sched_line
 from /bic/azvfosp1w00 
into table itab
for all entries in  itab_newcon 
where doc_number = itab_newcon-doc_number and
s_ord_item = itab_newcon-s_ord_item and
sched_line = itab_newcon-sched_line.


sort itab by  docno s_ord_item sched_line descending .
delete adjacent duplicates from itab comparing  docno s_ord_item sched_line .


loop at itab_newcon .

read table itab with key doc_number = itab_newcon-doc_number 
                                      S_ORD_ITEM = itab_newcon-S_ORD_ITEM 
                                      sched_line = itab_newcon-sched_line .
if sy-subrc = 0.
move-corresponding itab to wa_pdate.
wa_pdate-pdate = itab-/bic/zpviewdt.
APPEND wa_pdate to it_pdate.
endif.
endloop.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Vikranth&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Rob Burbank on Jan 7, 2010 9:41 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Jan 2010 13:19:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/avoid-max-selection-in-loop/m-p/6473928#M1417750</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-01-07T13:19:06Z</dc:date>
    </item>
    <item>
      <title>Re: Avoid max selection in loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/avoid-max-selection-in-loop/m-p/6473929#M1417751</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HI Siegfried Boes &lt;SPAN __jive_emoticon_name="happy"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;what i exactly meant for all entries without max function and then filtering the max values using a logic.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Jan 2010 13:20:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/avoid-max-selection-in-loop/m-p/6473929#M1417751</guid>
      <dc:creator>kesavadas_thekkillath</dc:creator>
      <dc:date>2010-01-07T13:20:11Z</dc:date>
    </item>
    <item>
      <title>Re: Avoid max selection in loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/avoid-max-selection-in-loop/m-p/6473930#M1417752</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HI vikranth,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Nice one &lt;SPAN __jive_emoticon_name="happy"&gt;&lt;/SPAN&gt; ... This didnt come to my mind &lt;SPAN __jive_emoticon_name="happy"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Jan 2010 13:21:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/avoid-max-selection-in-loop/m-p/6473930#M1417752</guid>
      <dc:creator>kesavadas_thekkillath</dc:creator>
      <dc:date>2010-01-07T13:21:32Z</dc:date>
    </item>
    <item>
      <title>Re: Avoid max selection in loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/avoid-max-selection-in-loop/m-p/6473931#M1417753</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;gt; And I can not generally be recommended to SELECT everything instead of use an aggregate function. The aggregate can &lt;/P&gt;&lt;P&gt;&amp;gt; dramatically reduce the number of transferred records. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please read carefully! The aggregate can avoid the transfer of thousands of lines, so it can not be recommended to omitt it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It can even be that this usage of the program aggregates only a few lines, but all other aggregate a lot.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So be careful with performance recommendations. Never recommend anything, which can turn into an even worse solution.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Siegfried&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Jan 2010 14:12:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/avoid-max-selection-in-loop/m-p/6473931#M1417753</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-01-07T14:12:29Z</dc:date>
    </item>
    <item>
      <title>Re: Avoid max selection in loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/avoid-max-selection-in-loop/m-p/6473932#M1417754</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt; hi Rui Pedro Dantas ,&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; For all entries with aggregate function is not possible.&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;oops, my mistake. i rarely use FAE, if that's an excuse.&lt;/P&gt;&lt;P&gt;i thought i remembered that it couldn't be used, but after skimming the F1 help I only say restrictions about ORDER BY and HAVING. but yes, you are right, if I remember correctly GROUP BY can be used but not aggregate fuctions.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Jan 2010 14:13:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/avoid-max-selection-in-loop/m-p/6473932#M1417754</guid>
      <dc:creator>Rui_Dantas</dc:creator>
      <dc:date>2010-01-07T14:13:20Z</dc:date>
    </item>
    <item>
      <title>Re: Avoid max selection in loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/avoid-max-selection-in-loop/m-p/6473933#M1417755</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;gt; read table itab &lt;/P&gt;&lt;P&gt;&amp;gt;           with key doc_number = itab_newcon-doc_number &lt;/P&gt;&lt;P&gt;&amp;gt;                 S_ORD_ITEM = itab_newcon-S_ORD_ITEM &lt;/P&gt;&lt;P&gt;&amp;gt;                   sched_line = itab_newcon-sched_line .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;even worse, NEVER use standard tables inside a loop with BINARY SEARCH&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt; sort itab by  docno s_ord_item sched_line descending .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Descending SORT is only used for display reasons !!!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Jan 2010 14:14:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/avoid-max-selection-in-loop/m-p/6473933#M1417755</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-01-07T14:14:52Z</dc:date>
    </item>
    <item>
      <title>Re: Avoid max selection in loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/avoid-max-selection-in-loop/m-p/6473934#M1417756</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Siegfried Boes ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So is it better to use a join along with aggregate instead of selecting all and processing with a descending sort?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I know it can be tested in ST05, if you dont mind please share your experience :).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I still remember this suggestion &lt;SPAN __jive_macro_name="thread" id="1375763"&gt;&lt;/SPAN&gt; &lt;SPAN __jive_emoticon_name="happy"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;One more addition &lt;SPAN __jive_emoticon_name="happy"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How will the binary search with standard internal tables reduce performance .. any peculiar reasons ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Keshav.T on Jan 7, 2010 7:56 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Jan 2010 14:20:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/avoid-max-selection-in-loop/m-p/6473934#M1417756</guid>
      <dc:creator>kesavadas_thekkillath</dc:creator>
      <dc:date>2010-01-07T14:20:53Z</dc:date>
    </item>
    <item>
      <title>Re: Avoid max selection in loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/avoid-max-selection-in-loop/m-p/6473935#M1417757</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Siegfried Boes  &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can you let me know how to tune it as i am new to ABAP&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i am basically a SAP BW consultant&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;path&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Jan 2010 14:28:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/avoid-max-selection-in-loop/m-p/6473935#M1417757</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-01-07T14:28:31Z</dc:date>
    </item>
    <item>
      <title>Re: Avoid max selection in loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/avoid-max-selection-in-loop/m-p/6473936#M1417758</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Vikranth.Reddy &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Fine with your code. can you let me know for the read statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;path&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Jan 2010 15:04:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/avoid-max-selection-in-loop/m-p/6473936#M1417758</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-01-07T15:04:08Z</dc:date>
    </item>
    <item>
      <title>Re: Avoid max selection in loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/avoid-max-selection-in-loop/m-p/6473937#M1417759</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;correction:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NEVER use withOUT BINARY SEARCH, as it is written in the example above.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Inside a loop you must faciliate a fast READ:&lt;/P&gt;&lt;P&gt;+ standard table with BINARY SEARCH&lt;/P&gt;&lt;P&gt;+ sorted table with table key or leading and selective part of the key&lt;/P&gt;&lt;P&gt;+ hashed table with full table key&lt;/P&gt;&lt;P&gt;(index accesses also fast, but the index is usually unknown)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Jan 2010 15:04:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/avoid-max-selection-in-loop/m-p/6473937#M1417759</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-01-07T15:04:36Z</dc:date>
    </item>
    <item>
      <title>Re: Avoid max selection in loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/avoid-max-selection-in-loop/m-p/6473938#M1417760</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;coming back to the original question:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;+ How many records are in itab_newcon ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;+ You can test the usefulness of the aggregate by testing this one:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
select * 
           from /bic/azvfosp1w00 
           where doc_number = itab_newcon-doc_number 
           and    s_ord_item = itab_newcon-s_ord_item 
           and    sched_line = itab_newcon-sched_line.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;directly with the SE16 (display of table content), you must type in example values for the 3 fields.&lt;/P&gt;&lt;P&gt;How many records come back?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can run an SQL-trace in parallel just for this statement. How long does it need? Maybe your problem is&lt;/P&gt;&lt;P&gt;connected to the selection and not at all to the max function. Which index is used?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Usage of SQL-trace is simple in this case, just call it start it, execute the selection, stop it and display the result.&lt;/P&gt;&lt;P&gt;Times are in microseconds.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Siegfried&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Jan 2010 15:15:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/avoid-max-selection-in-loop/m-p/6473938#M1417760</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-01-07T15:15:10Z</dc:date>
    </item>
    <item>
      <title>Re: Avoid max selection in loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/avoid-max-selection-in-loop/m-p/6473939#M1417761</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Siegfried Boes ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; got information from basis that due to my program there were many deadlocks&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;is it necessary to use &lt;STRONG&gt;commit&lt;/STRONG&gt; statement over there&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please look into the code&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Read all records in active table of ODS into itab_ord&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;select * from /BIC/AZVFOSDP200&lt;/P&gt;&lt;P&gt;appending corresponding fields of table itab_ord&lt;/P&gt;&lt;P&gt;where /BIC/ZPVIEWDT &amp;gt; '19900101'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;commit.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Insert Changes&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;loop at itab_omod where SID eq ' '.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;itab_omod-sid = zarequest.&lt;/P&gt;&lt;P&gt;itab_omod-datapakid = zadatapakid.&lt;/P&gt;&lt;P&gt;itab_omod-record = zarecord.&lt;/P&gt;&lt;P&gt;modify itab_omod.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;zarecord = zarecord + 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;insert into /BIC/AZVFOSDP240 values itab_omod.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;commit.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Changing the contents of new table with the value&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;MODIFY /BIC/AZVFOSDP240 from table itab_neword.&lt;/P&gt;&lt;P&gt;commit&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Path&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Jan 2010 15:23:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/avoid-max-selection-in-loop/m-p/6473939#M1417761</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-01-07T15:23:13Z</dc:date>
    </item>
    <item>
      <title>Re: Avoid max selection in loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/avoid-max-selection-in-loop/m-p/6473940#M1417762</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;LOL rightly hit by Siegfried as expected. The docno miss in the sort statement was a typo and thanks to Rob for correcting it:-) I think using a sorted internal table with binary search addition to the read statement should make the code decent. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Vikranth&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Jan 2010 16:57:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/avoid-max-selection-in-loop/m-p/6473940#M1417762</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-01-07T16:57:03Z</dc:date>
    </item>
    <item>
      <title>Re: Avoid max selection in loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/avoid-max-selection-in-loop/m-p/6473941#M1417763</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;funny, but everything off-topic ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. The reason for the problem is still not clear, it is not even clear whether there is at all a problem, maybe there is simply &lt;/P&gt;&lt;P&gt;    a lot to be done:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    Coding&lt;/P&gt;&lt;P&gt;    The max-aggregate can give you the max of 10 or of 1000 .... 10000 lines.&lt;/P&gt;&lt;P&gt;    The change of SELECT in LOOP into a FAE can make sense if the LOOP is large.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    2 Parameter, nobody known how large they are. =&amp;gt; Not clear which one is better.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. SELECTION to an unknowen table what is index? Maybe this is the reason for the problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;... so analyse first before you advice ....&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Jan 2010 08:31:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/avoid-max-selection-in-loop/m-p/6473941#M1417763</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-01-08T08:31:52Z</dc:date>
    </item>
  </channel>
</rss>

