<?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 NESTED SELECT - ENDSELECT in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/nested-select-endselect/m-p/3128119#M742985</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 HAVE ONE DOUBT. IF WE HAVE  STATEMENT LIKE &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT  &lt;/P&gt;&lt;P&gt;   SELECT &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;   ENDSELECT&lt;/P&gt;&lt;P&gt;ENDSELECT&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;THEN WE CAN USE &lt;/P&gt;&lt;P&gt;SELECT  &lt;/P&gt;&lt;P&gt;  READ TABLE ................&lt;/P&gt;&lt;P&gt;ENDSELECT&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i AM FACING A PROBLEM  WHERE I HAVE TO USE THIS STATEMENT &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT&lt;/P&gt;&lt;P&gt;  SELECT  &lt;/P&gt;&lt;P&gt;     SELECT &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      ENDSELECT&lt;/P&gt;&lt;P&gt;  ENDSELECT&lt;/P&gt;&lt;P&gt;ENDSELECT&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CAN ANY ONE GIVE ME AN ALTERNATIVE FOR THIS WITH SUITABLKE EXAMPLE.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 29 Nov 2007 17:34:18 GMT</pubDate>
    <dc:creator>former_member329386</dc:creator>
    <dc:date>2007-11-29T17:34:18Z</dc:date>
    <item>
      <title>NESTED SELECT - ENDSELECT</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/nested-select-endselect/m-p/3128119#M742985</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 HAVE ONE DOUBT. IF WE HAVE  STATEMENT LIKE &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT  &lt;/P&gt;&lt;P&gt;   SELECT &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;   ENDSELECT&lt;/P&gt;&lt;P&gt;ENDSELECT&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;THEN WE CAN USE &lt;/P&gt;&lt;P&gt;SELECT  &lt;/P&gt;&lt;P&gt;  READ TABLE ................&lt;/P&gt;&lt;P&gt;ENDSELECT&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i AM FACING A PROBLEM  WHERE I HAVE TO USE THIS STATEMENT &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT&lt;/P&gt;&lt;P&gt;  SELECT  &lt;/P&gt;&lt;P&gt;     SELECT &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      ENDSELECT&lt;/P&gt;&lt;P&gt;  ENDSELECT&lt;/P&gt;&lt;P&gt;ENDSELECT&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CAN ANY ONE GIVE ME AN ALTERNATIVE FOR THIS WITH SUITABLKE EXAMPLE.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Nov 2007 17:34:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/nested-select-endselect/m-p/3128119#M742985</guid>
      <dc:creator>former_member329386</dc:creator>
      <dc:date>2007-11-29T17:34:18Z</dc:date>
    </item>
    <item>
      <title>Re: NESTED SELECT - ENDSELECT</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/nested-select-endselect/m-p/3128120#M742986</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Use inner join instead of writing nested select stmts.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Naveen.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Nov 2007 17:41:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/nested-select-endselect/m-p/3128120#M742986</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-11-29T17:41:42Z</dc:date>
    </item>
    <item>
      <title>Re: NESTED SELECT - ENDSELECT</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/nested-select-endselect/m-p/3128121#M742987</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;Nested SELECT loops mean that the number of accesses in the inner loop is multiplied by the number of accesses in the outer loop. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Using &amp;lt;b&amp;gt;nested selects is a technique with low performance&amp;lt;/b&amp;gt;. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Instead of nested SELECT statements the joins INNER or OUTER should be used or VIEWS should be created in ABAP DICTIONARY if possibel another&lt;/P&gt;&lt;P&gt;alternative is to use &lt;/P&gt;&lt;P&gt;FOR ALL ENTRIES IN itab&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;If we use FOR ALL ENTRIES IN itab , care should be taken that it is not&lt;/P&gt;&lt;P&gt;empty otherwise DBMS will return all the rows from the table specified&lt;/P&gt;&lt;P&gt;in the FROM clause of SELECT statement .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can use the following techniques to avoid nested SELECT statements:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;ABAP Dictionary Views&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;You can define joins between database tables statically and systemwide as views in the ABAP Dictionary. Such views can be used by all ABAP programs. One of their advantages is that fields that are common to both tables (join fields) are only transferred once from the database to the application server. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Views in the ABAP Dictionary are implemented as inner joins. If the inner table contains no lines that correspond to lines in the outer table, no data is transferred. This is not always the desired result. For example, when you read data from a text table, you want to include lines in the selection even if the corresponding text does not exist in the required language. If you want to include all of the data from the outer table, you can program a left outer join in ABAP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The links between the tables in the view are created and optimized by the database system. Like database tables, you can buffer views on the application server. The same buffering rules apply to views as to tables. In other words, it is most appropriate for views that you use mostly to read data. This reduces the network load and the amount of physical I/O in the database. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;Joins in the FROM Clause&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;You can read data from more than one database table in a single SELECT statement by using inner or left outer joins in the FROM clause. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The disadvantage of using joins is that redundant data is read from the hierarchically-superior table if there is a 1:N relationship between the outer and inner tables. This can considerably increase the amount of data transferred from the database to the application server. Therefore, when you program a join, you should ensure that the SELECT clause contains a list of only the columns that you really need. Furthermore, joins bypass the table buffer and read directly from the database. For this reason, you should use an ABAP Dictionary view instead of a join if you only want to read the data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The runtime of a join statement is heavily dependent on the database optimizer, especially when it contains more than two database tables. However, joins are nearly always quicker than using nested SELECT statements.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;Subqueries in the WHERE and HAVING Clauses&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;Another way of accessing more than one database table in the same Open SQL statement is to use subqueries in the WHERE or HAVING clause. The data from a subquery is not transferred to the application server. Instead, it is used to evaluate conditions in the database system. This is a simple and effective way of programming complex database operations.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;Using Internal Tables&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;It is also possible to avoid nested SELECT loops by placing the selection from the outer loop in an internal table and then running the inner selection once only using the FOR ALL ENTRIES addition. This technique stems from the time before joins were allowed in the FROM clause. On the other hand, it does prevent redundant data from being transferred from the database.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Maha&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Nov 2007 18:38:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/nested-select-endselect/m-p/3128121#M742987</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-11-29T18:38:19Z</dc:date>
    </item>
    <item>
      <title>Re: NESTED SELECT - ENDSELECT</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/nested-select-endselect/m-p/3128122#M742988</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;Please use one of the following&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. Create views and select from the view. Alternatively you could also use inner joins.&lt;/P&gt;&lt;P&gt;2. FOR all entries is also a good option. Please remember to give complete primary keys in the where clause, also select all the primary keys as a part of your field list in select.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Nested select is good to learn in the initial stages, but is not used in professional coding due to performance issues. Infact in Code review checklist of all projects this is a 'not to do' item.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Nov 2007 18:59:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/nested-select-endselect/m-p/3128122#M742988</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-11-29T18:59:27Z</dc:date>
    </item>
  </channel>
</rss>

