<?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: Problem with select statement in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-select-statement/m-p/1186713#M127380</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;use FOR ALL ENTRIES and equate the common fields 

select fld1 fld2
       from ztab1 
       into table itab1.

if not itab1[] is initial
  select fld1 fld3
       from ztab2 
       into table itab2
       for all entries in itab1 
       where fld1 = itab1-fld1.
endif.
 
if not itab2[] is initial
  select fld3 fld4
       from ztab3 
       into table itab3
       for all entries in itab2 
       where fld3 = itab2-fld3.
endif.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: Sekhar&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 22 Feb 2006 16:30:38 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2006-02-22T16:30:38Z</dc:date>
    <item>
      <title>Problem with select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-select-statement/m-p/1186709#M127376</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;In my code I have diferents selects of seven tables but for best performance I want to insert them in diferents internal tables. But I don't know how make the relations between the selects if I use seven internal tables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need to put the statement FOR ALL ENTRIES in every select? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the help!!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Feb 2006 16:24:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-select-statement/m-p/1186709#M127376</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-02-22T16:24:25Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-select-statement/m-p/1186710#M127377</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;you can use for all entries for selecting the data from the database using the internal tables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;otherwise&lt;/P&gt;&lt;P&gt;you can use&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sort itab.&lt;/P&gt;&lt;P&gt;loop at itab.&lt;/P&gt;&lt;P&gt;Read Table &amp;lt;internal table&amp;gt; with key &amp;lt;field name&amp;gt; = itab-field.&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;kishore&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Feb 2006 16:29:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-select-statement/m-p/1186710#M127377</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-02-22T16:29:00Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-select-statement/m-p/1186711#M127378</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Carlos,&lt;/P&gt;&lt;P&gt;  If you have common fields in more than one table,then do a join on those tables.&lt;/P&gt;&lt;P&gt;&amp;amp; then use FOR ALL ENTRIES.&lt;/P&gt;&lt;P&gt;Or you can use FOR ALL ENTRIES on all the internal tables checking for the previous internal table data existence.&lt;/P&gt;&lt;P&gt;like IF NOT ITAB[] IS INITIAL.&lt;/P&gt;&lt;P&gt;         your select here.&lt;/P&gt;&lt;P&gt;     ENDIF.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Feb 2006 16:29:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-select-statement/m-p/1186711#M127378</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-02-22T16:29:23Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-select-statement/m-p/1186712#M127379</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can you please give the tables name and what exactly out put you&amp;#146;re looking for... then we can help you out.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Feb 2006 16:30:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-select-statement/m-p/1186712#M127379</guid>
      <dc:creator>former_member181966</dc:creator>
      <dc:date>2006-02-22T16:30:32Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-select-statement/m-p/1186713#M127380</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;use FOR ALL ENTRIES and equate the common fields 

select fld1 fld2
       from ztab1 
       into table itab1.

if not itab1[] is initial
  select fld1 fld3
       from ztab2 
       into table itab2
       for all entries in itab1 
       where fld1 = itab1-fld1.
endif.
 
if not itab2[] is initial
  select fld3 fld4
       from ztab3 
       into table itab3
       for all entries in itab2 
       where fld3 = itab2-fld3.
endif.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: Sekhar&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Feb 2006 16:30:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-select-statement/m-p/1186713#M127380</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-02-22T16:30:38Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-select-statement/m-p/1186714#M127381</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;Check the select statement with join and with out join using for all entries statement.whenever you are using for all entries on particualr internal table , first check the internal table contents , if it is not blank , then use for all entries statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If not i_first[] is initial.&lt;/P&gt;&lt;P&gt;SELECT * FROM ztab                                    &lt;/P&gt;&lt;P&gt;         INTO TABLE i_tab FOR ALL ENTRIES IN i_first &lt;/P&gt;&lt;P&gt;         WHERE zf1 =  i_first-f1.       &lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If not i_first[] is initial.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT a~fld1                                         &lt;/P&gt;&lt;P&gt;          b~fld1                                          &lt;/P&gt;&lt;P&gt;       INTO CORRESPONDING FIELDS OF TABLE i_tab          &lt;/P&gt;&lt;P&gt;       FROM ztab1 AS a INNER JOIN ztab2 AS b                       &lt;/P&gt;&lt;P&gt;       ON   a&lt;SUB&gt;fld1 = b&lt;/SUB&gt;fld1                               &lt;/P&gt;&lt;P&gt;       FOR ALL ENTRIES IN i_first                              &lt;/P&gt;&lt;P&gt;     WHERE  a~fld1  =  i_first-fl1.                     &lt;/P&gt;&lt;P&gt;                              &lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Feb 2006 16:33:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-select-statement/m-p/1186714#M127381</guid>
      <dc:creator>Laxmana_Appana_</dc:creator>
      <dc:date>2006-02-22T16:33:09Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-select-statement/m-p/1186715#M127382</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi carlos,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;first get the data from one of the table into a separate internal table and based on the common field (i.e primary key) in that table, get the data from other internal tables using FOR ALL ENTRIES OF addition&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sample code:&lt;/P&gt;&lt;P&gt;    select kschl&lt;/P&gt;&lt;P&gt;           vtext&lt;/P&gt;&lt;P&gt;           into table dt_kschl_desc&lt;/P&gt;&lt;P&gt;           from t685t&lt;/P&gt;&lt;P&gt;           for all entries in dt_cond_tables&lt;/P&gt;&lt;P&gt;           where kschl = dt_cond_tables-kschl.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;mahesh.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Feb 2006 16:36:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-select-statement/m-p/1186715#M127382</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-02-22T16:36:03Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-select-statement/m-p/1186716#M127383</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;what are your tables, and if there are any common fields then you can go for for all entries. this will reduce the load .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;vijay&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Feb 2006 16:37:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-select-statement/m-p/1186716#M127383</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-02-22T16:37:55Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-select-statement/m-p/1186717#M127384</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This are my tables:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
TABLES:

         payr,   
                
        reguh,             

        regup,                     

        reguv,                    

        t001,                      

        bkpf,                      

        pcec,                      
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Feb 2006 17:02:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-select-statement/m-p/1186717#M127384</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-02-22T17:02:14Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-select-statement/m-p/1186718#M127385</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi carlos,&lt;/P&gt;&lt;P&gt;   yeah like,&lt;/P&gt;&lt;P&gt;1. look out for relationship between the seven tables&lt;/P&gt;&lt;P&gt;2. separate the seven tables based on the header,item  &lt;/P&gt;&lt;P&gt;   relationships like likp&lt;DEL&gt;&amp;gt; delivery header and lips&lt;/DEL&gt;&amp;gt;delivey at item level .&lt;/P&gt;&lt;P&gt;if this is the case then u can opt for 'For all entries' .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3. or if 3-4 tables are having a primary and foreign key occurance as in MARA,MARC,MARD,MAKT tables then u can go for join(inner).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;see if u can go for less select(s) then that also increase the performance .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;4. u can go for the options but if u can name the seven tables then a correct solution can be estimated depending on the query.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;vijay.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Feb 2006 17:07:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-select-statement/m-p/1186718#M127385</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-02-22T17:07:54Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-select-statement/m-p/1186719#M127386</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HI Carlos&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As i said earlier you can try those two methods in which read table is efficient in performance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select * into table itab from payr where ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select * into table itab1 from reguh where....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at itab.&lt;/P&gt;&lt;P&gt;write: itab-field.&lt;/P&gt;&lt;P&gt;read table itab1 with key field = itab-field.&lt;/P&gt;&lt;P&gt;write itab1-field.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;otherwise you can use for all entries&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select * into table itab1 from regun for all entries in itab where field = itab-field.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;kishore&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Feb 2006 17:08:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-select-statement/m-p/1186719#M127386</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-02-22T17:08:37Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-select-statement/m-p/1186720#M127387</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;carlos ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;T001 - use this in at-selection screen .&lt;/P&gt;&lt;P&gt;and in the code if required but this is for checking the company code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;bkpf --&amp;gt; this is account document header , so go for select , as BELNR(accounting document number) fiscal year(GJAHR) is to be computed okay this is main in this table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;reguh is header and regup is at item level ,&lt;/P&gt;&lt;P&gt;apply single select with joins and for all entries in the same select so there is scope of reducing one exra select .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PAYR and PCEC again has foreign key relation ship for company code ZBUKR .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;so for all entries in the above tables u can select the info from the table using joins(inner) .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;so u need not put select for every table okay . &lt;/P&gt;&lt;P&gt;i think 4-5 selects will do to ur code .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;use if not itab1[] is not initial then go for populating the second internal table .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;use select distinct/single/* depending on the criterion .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;check out for duplicates also .. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;vijay.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Feb 2006 17:33:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-select-statement/m-p/1186720#M127387</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-02-22T17:33:06Z</dc:date>
    </item>
  </channel>
</rss>

