<?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: Select to Database or Loop in Program in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-to-database-or-loop-in-program/m-p/10266273#M1830713</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yeah , bro if it is single value then we can use Read statement but, if we want multiple values from inner loop then we&amp;nbsp; need to provide loop not read statement. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 29 Apr 2014 12:04:43 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2014-04-29T12:04:43Z</dc:date>
    <item>
      <title>Select to Database or Loop in Program</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-to-database-or-loop-in-program/m-p/10266266#M1830706</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello gurus,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please help me out for best programming skills, which is best using Select statement in Loop&amp;nbsp; to fetch data or get whole data from database using select statement once and looping with conditions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example&amp;nbsp; TAB is a table with A, B, C , D conditions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1st method: Select A B C D from TAB into ITAB.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; then loop itab with some condtion.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2nd method : loop then Select statement with condition.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. TAB1 and TAB2 , two select statements to fetch data from tables, then loop on TAB1 and then in this loop another loop for TAB2 for populate data into output table . output like&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; TAB1-FIELD-A TAB2-FIELD-A&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; TAB1-FIELD-A&amp;nbsp; TAB2 -FIELD-B&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. Or Loop at TAB1 and then select statement on TAB2 from database to fetch data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So here my doubt is .. in 2 example heavy data is there, then under Loop of TAB1 , select statement hits database that many times&amp;nbsp; but in&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1 example select statement on database only one time then loop under loop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So Loop under loop or Select statement to hit database repeats, which one better.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Apr 2014 11:32:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-to-database-or-loop-in-program/m-p/10266266#M1830706</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2014-04-29T11:32:28Z</dc:date>
    </item>
    <item>
      <title>Re: Select to Database or Loop in Program</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-to-database-or-loop-in-program/m-p/10266267#M1830707</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;We should always try to hit the data base table only once in one program context .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Bhanu.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Apr 2014 11:44:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-to-database-or-loop-in-program/m-p/10266267#M1830707</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2014-04-29T11:44:05Z</dc:date>
    </item>
    <item>
      <title>Re: Select to Database or Loop in Program</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-to-database-or-loop-in-program/m-p/10266268#M1830708</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Consult,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i would select data of tab 1 into sorted table1, data of tab 2 into hashed table 2 for all entries in tab 1.&lt;/P&gt;&lt;P&gt;then loop at sorted tab 1 and read hashed tab 2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;+ loop at sorted itab is fastest way for loop&lt;/P&gt;&lt;P&gt;+ read big data on hashed itab is fastest way&lt;/P&gt;&lt;P&gt;+ loop at smaller itab and read hashed big itab&lt;/P&gt;&lt;P&gt;+ use field symbols for read and loop statement&lt;/P&gt;&lt;P&gt;+ always select data in one time if possible and not many single selects (big database traffic and overhead)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just my 5 cents&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards Wolfgang&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Apr 2014 11:45:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-to-database-or-loop-in-program/m-p/10266268#M1830708</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2014-04-29T11:45:49Z</dc:date>
    </item>
    <item>
      <title>Re: Select to Database or Loop in Program</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-to-database-or-loop-in-program/m-p/10266269#M1830709</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;Do not use SELECT in loop. Fetch the data first from the database table and do rest of the processing on the internal tables using LOOP, READ etc. Many times depending on business logic you might need to change the approach if it is completely unavoidable. So, for your question, method 1 is better. &lt;SPAN __jive_emoticon_name="happy" __jive_macro_name="emoticon" class="jive_macro_emoticon jive_macro jive_emote" src="https://community.sap.com/748/images/emoticons/happy.gif"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Shahir Mirza&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Apr 2014 11:52:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-to-database-or-loop-in-program/m-p/10266269#M1830709</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2014-04-29T11:52:29Z</dc:date>
    </item>
    <item>
      <title>Re: Select to Database or Loop in Program</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-to-database-or-loop-in-program/m-p/10266270#M1830710</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; It's always better to hit the database as less as possible. So, get your data in one shot. And if the tables are related, better to use INNER JOIN to get final data. INNER JOIN will be much faster.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Anubhab&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Apr 2014 11:55:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-to-database-or-loop-in-program/m-p/10266270#M1830710</guid>
      <dc:creator>anubhab</dc:creator>
      <dc:date>2014-04-29T11:55:03Z</dc:date>
    </item>
    <item>
      <title>Re: Select to Database or Loop in Program</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-to-database-or-loop-in-program/m-p/10266271#M1830711</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;first use select statement to get all the possible&amp;nbsp; values from database then loop it...inside loop you use read statement for operations..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;hope this makes ur doubt clear...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Apr 2014 11:58:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-to-database-or-loop-in-program/m-p/10266271#M1830711</guid>
      <dc:creator>former_member206650</dc:creator>
      <dc:date>2014-04-29T11:58:17Z</dc:date>
    </item>
    <item>
      <title>Re: Select to Database or Loop in Program</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-to-database-or-loop-in-program/m-p/10266272#M1830712</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes , Hitting database or select statement is the most important issue for ABAPer . Because we should not hit database more.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But there are times , when reports need data to be fetched from more tables like 10 above then that time , Loops will be more , then which one will be the best. &lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;More loops under loop will give short dump..?? Loops will be problem..??&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;At any cost we should not use Select statement under loops..?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;My view for above statement is . Yes we should not use Select statement under Loops it is much bigger problem than Loop under loops.&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Apr 2014 12:03:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-to-database-or-loop-in-program/m-p/10266272#M1830712</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2014-04-29T12:03:26Z</dc:date>
    </item>
    <item>
      <title>Re: Select to Database or Loop in Program</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-to-database-or-loop-in-program/m-p/10266273#M1830713</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yeah , bro if it is single value then we can use Read statement but, if we want multiple values from inner loop then we&amp;nbsp; need to provide loop not read statement. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Apr 2014 12:04:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-to-database-or-loop-in-program/m-p/10266273#M1830713</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2014-04-29T12:04:43Z</dc:date>
    </item>
    <item>
      <title>Re: Select to Database or Loop in Program</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-to-database-or-loop-in-program/m-p/10266274#M1830714</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Loop about itabs is ALLWAYS faster than many single database selects!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Get the database data in one time (for all entries or inner Joins) if possible and do the rest by loops. Sometimes it is helpfull to create compressed itabs to read database in one time (for example you read 2000 orders with 10.000 items, but with only 100 different materials. To get data for material it is better to compress first materials into a own itab to read MARA etc. with 100 items instead of reading with 10.000 line items)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Apr 2014 12:12:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-to-database-or-loop-in-program/m-p/10266274#M1830714</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2014-04-29T12:12:35Z</dc:date>
    </item>
    <item>
      <title>Re: Select to Database or Loop in Program</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-to-database-or-loop-in-program/m-p/10266275#M1830715</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;ur observation is right but in the loop u can use where&amp;nbsp; statement then do the operations...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Apr 2014 12:16:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-to-database-or-loop-in-program/m-p/10266275#M1830715</guid>
      <dc:creator>former_member206650</dc:creator>
      <dc:date>2014-04-29T12:16:55Z</dc:date>
    </item>
    <item>
      <title>Re: Select to Database or Loop in Program</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-to-database-or-loop-in-program/m-p/10266276#M1830716</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;It is not good to select data in loop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. First select the data&lt;/P&gt;&lt;P&gt;2. Loop on selected data.&lt;/P&gt;&lt;P&gt;3. If there is a need of Loop inside Loop, Use Parallel Cursor Techinque.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks and Regards,&lt;/P&gt;&lt;P&gt;Shakeer Hussain&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Apr 2014 12:17:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-to-database-or-loop-in-program/m-p/10266276#M1830716</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2014-04-29T12:17:28Z</dc:date>
    </item>
    <item>
      <title>Re: Select to Database or Loop in Program</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-to-database-or-loop-in-program/m-p/10266277#M1830717</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The best option is&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3. TAB1 and TAB2, one select statement (JOIN) to fetch data from both tables into output table, done.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thomas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Apr 2014 12:17:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-to-database-or-loop-in-program/m-p/10266277#M1830717</guid>
      <dc:creator>ThomasZloch</dc:creator>
      <dc:date>2014-04-29T12:17:33Z</dc:date>
    </item>
    <item>
      <title>Re: Select to Database or Loop in Program</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-to-database-or-loop-in-program/m-p/10266278#M1830718</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If this is possible (no cluster/pool table) and useful (not a buffered table with a high hit ratio, and never for a fully buffered table) try to use a JOIN option in a single statement. As much as possible, only&lt;/P&gt;&lt;P&gt;SELECT data from buffered tables in a LOOP. There is also the option of using a second select with a FOR ALL ENTRIES IN the first extracted table but that may result in performance problem, especially for high volume of data and incomplete key mapping, but that is almost always better than the SELECT in the LOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Raymond&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Apr 2014 07:17:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-to-database-or-loop-in-program/m-p/10266278#M1830718</guid>
      <dc:creator>RaymondGiuseppi</dc:creator>
      <dc:date>2014-04-30T07:17:13Z</dc:date>
    </item>
    <item>
      <title>Re: Select to Database or Loop in Program</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-to-database-or-loop-in-program/m-p/10266279#M1830719</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So, actually when database is triggered multiple times , its a performance issue. Then how to know that database has been taken hit these many times. We can know the sql query time but how to know that ??, these many times database has been hit and due to this performance issue is ther . &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Jun 2014 06:20:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-to-database-or-loop-in-program/m-p/10266279#M1830719</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2014-06-16T06:20:00Z</dc:date>
    </item>
  </channel>
</rss>

