<?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: Re querying a table using ONE Select in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/re-querying-a-table-using-one-select/m-p/8184653#M1624615</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Clemens,&lt;/P&gt;&lt;P&gt;Ok..I thought of making my question in a  more generalized way so i avoided specifying the tables. &lt;/P&gt;&lt;P&gt;Here you go.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1) Select vertrag vkonto  into table it_ever&lt;/P&gt;&lt;P&gt;       from EVER&lt;/P&gt;&lt;P&gt;     where ainzdat in s_moveout.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if not it_ever[] is initial.&lt;/P&gt;&lt;P&gt;2) select vkont gpart into table it_fkkvkp &lt;/P&gt;&lt;P&gt;      from FKKVKP  for all entries in it_vkont&lt;/P&gt;&lt;P&gt;   where vkont = it_ever-vkonto.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3) 1 vkont will have multiple vertrags in EVER :  From above vkonts in it_fkkvkp, I need to hit  EVER again as below which i DONT like.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if it_fkkvkp[] is initial.&lt;/P&gt;&lt;P&gt;select vertrag vkonto into table it_ever2 &lt;/P&gt;&lt;P&gt;where vkonto = it_fkkvkp-vkont.&lt;/P&gt;&lt;P&gt;endif.    &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;so i am thinking of some table aliaisng on it_fkkvkp.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 27 Aug 2011 13:10:17 GMT</pubDate>
    <dc:creator>ricky_shaw</dc:creator>
    <dc:date>2011-08-27T13:10:17Z</dc:date>
    <item>
      <title>Re querying a table using ONE Select</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/re-querying-a-table-using-one-select/m-p/8184646#M1624608</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Experts,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In one hit i want to query a Table2 2 times using oNE select query&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Lets say, i have 2 database tables  : Table1 &amp;amp; Table2.&lt;/P&gt;&lt;P&gt;&amp;amp; internal tables say itab1 &amp;amp; itab2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Lets say they have fields:  fld1 fld 2 fld3 fld4.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1) I used select * from Table1 into table itab1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2) Now i want to get entries from table2 based on itab-fld1 and itab2-fld4&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;select * from Table2 into itab2
 FOR ALL ENTRIES in itab1
where fld1 = itab1-fld1
  and fld2 = *itab2-fld4*  (entries based on 
itab2)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please suggest.,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Ricky&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Aug 2011 19:53:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/re-querying-a-table-using-one-select/m-p/8184646#M1624608</guid>
      <dc:creator>ricky_shaw</dc:creator>
      <dc:date>2011-08-25T19:53:50Z</dc:date>
    </item>
    <item>
      <title>Re: Re querying a table using ONE Select</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/re-querying-a-table-using-one-select/m-p/8184647#M1624609</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;I have not done before, but can sense it can be solved through sub query....&lt;/P&gt;&lt;P&gt;Please read documentation of SELECT...WHERE IN EXIST....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Aug 2011 20:07:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/re-querying-a-table-using-one-select/m-p/8184647#M1624609</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-08-25T20:07:02Z</dc:date>
    </item>
    <item>
      <title>Re: Re querying a table using ONE Select</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/re-querying-a-table-using-one-select/m-p/8184648#M1624610</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;I am not sure we can directly assign like this, But you can have one SELECT and get the solution.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have never tried this, but have a look into this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://help.sap.com/saphelp_nw04/helpdata/EN/dc/dc7614099b11d295320000e8353423/content.htm" target="test_blank"&gt;http://help.sap.com/saphelp_nw04/helpdata/EN/dc/dc7614099b11d295320000e8353423/content.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Shiva&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Aug 2011 20:20:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/re-querying-a-table-using-one-select/m-p/8184648#M1624610</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-08-25T20:20:36Z</dc:date>
    </item>
    <item>
      <title>Re: Re querying a table using ONE Select</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/re-querying-a-table-using-one-select/m-p/8184649#M1624611</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, &lt;/P&gt;&lt;P&gt;How can i use JOIN here? The main filter is in Table2 itself on  fld4 .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Aug 2011 20:23:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/re-querying-a-table-using-one-select/m-p/8184649#M1624611</guid>
      <dc:creator>ricky_shaw</dc:creator>
      <dc:date>2011-08-25T20:23:35Z</dc:date>
    </item>
    <item>
      <title>Re: Re querying a table using ONE Select</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/re-querying-a-table-using-one-select/m-p/8184650#M1624612</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ricky,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;this is a possible case for ALIAS, but you must get rid of *. SELECT * is translated by DB interface in to all available fields.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT table1~fld1 table2~fld2 table1~fld3 table2~fld4 table1~fld5 ...
  INTO CORRESPONDING FIELDS OF itab_x
  FROM table1
  JOIN table1 as table2
    ON table1~fld1 = table2~fld3 AND
       table1~fld2 = table2~fld4
   WHERE ...&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;    &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Clemens&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Aug 2011 22:15:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/re-querying-a-table-using-one-select/m-p/8184650#M1624612</guid>
      <dc:creator>Clemenss</dc:creator>
      <dc:date>2011-08-25T22:15:23Z</dc:date>
    </item>
    <item>
      <title>Re: Re querying a table using ONE Select</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/re-querying-a-table-using-one-select/m-p/8184651#M1624613</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Celemens, &lt;/P&gt;&lt;P&gt;i DONT  see that you are making use of any field from  itab_x.&lt;/P&gt;&lt;P&gt;Ok. just IGNORE  table1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now please tell me how can i write aliasing?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT  table2&lt;SUB&gt;fld2  table2&lt;/SUB&gt;fld4 &lt;/P&gt;&lt;P&gt;  INTO CORRESPONDING FIELDS OF itab_x&lt;/P&gt;&lt;P&gt;  FROM table2&lt;/P&gt;&lt;P&gt;   WHERE &lt;/P&gt;&lt;P&gt;fld2 = itab_x-fld2..&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;Ricky&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 26 Aug 2011 21:30:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/re-querying-a-table-using-one-select/m-p/8184651#M1624613</guid>
      <dc:creator>ricky_shaw</dc:creator>
      <dc:date>2011-08-26T21:30:16Z</dc:date>
    </item>
    <item>
      <title>Re: Re querying a table using ONE Select</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/re-querying-a-table-using-one-select/m-p/8184652#M1624614</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ricky,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;it is almost impossible to explain anything if you do not have an example of what you are going to do. When I say example, I don not mean &lt;EM&gt;Lets say, i have 2 database tables&lt;/EM&gt; or &lt;EM&gt;Lets say they have fields&lt;/EM&gt; but a case that everyone understands.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you are talking about SAP tables, give the names and fields. If you are talking about user-defined tables, decribe the process, give table and field names and characteristics (data element, domain, check table, search help...) of each field.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For the question &lt;EM&gt;Now please tell me how can i write aliasing&lt;/EM&gt; the answer is a clear F1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Shortly: If you write &amp;lt;tabname&amp;gt; AS &amp;lt;alias&amp;gt; or &amp;lt;fieldname&amp;gt; AS &amp;lt;alias&amp;gt; this means that &amp;lt;tabname&amp;gt; and &amp;lt;fieldname&amp;gt; identifie table and field in the database and &amp;lt;alias&amp;gt; is used for it in the query clause and for the data transfer from database to INTO data object.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note: It is always better to ask a question for a specific task. Getting the answer you can use it in all tasks that are comparable to the one you asked for. Asking a bla-bla question ( &lt;EM&gt;Lets say...&lt;/EM&gt; ) will rarely get a useful answer.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Clermens&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 27 Aug 2011 09:49:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/re-querying-a-table-using-one-select/m-p/8184652#M1624614</guid>
      <dc:creator>Clemenss</dc:creator>
      <dc:date>2011-08-27T09:49:07Z</dc:date>
    </item>
    <item>
      <title>Re: Re querying a table using ONE Select</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/re-querying-a-table-using-one-select/m-p/8184653#M1624615</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Clemens,&lt;/P&gt;&lt;P&gt;Ok..I thought of making my question in a  more generalized way so i avoided specifying the tables. &lt;/P&gt;&lt;P&gt;Here you go.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1) Select vertrag vkonto  into table it_ever&lt;/P&gt;&lt;P&gt;       from EVER&lt;/P&gt;&lt;P&gt;     where ainzdat in s_moveout.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if not it_ever[] is initial.&lt;/P&gt;&lt;P&gt;2) select vkont gpart into table it_fkkvkp &lt;/P&gt;&lt;P&gt;      from FKKVKP  for all entries in it_vkont&lt;/P&gt;&lt;P&gt;   where vkont = it_ever-vkonto.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3) 1 vkont will have multiple vertrags in EVER :  From above vkonts in it_fkkvkp, I need to hit  EVER again as below which i DONT like.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if it_fkkvkp[] is initial.&lt;/P&gt;&lt;P&gt;select vertrag vkonto into table it_ever2 &lt;/P&gt;&lt;P&gt;where vkonto = it_fkkvkp-vkont.&lt;/P&gt;&lt;P&gt;endif.    &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;so i am thinking of some table aliaisng on it_fkkvkp.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 27 Aug 2011 13:10:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/re-querying-a-table-using-one-select/m-p/8184653#M1624615</guid>
      <dc:creator>ricky_shaw</dc:creator>
      <dc:date>2011-08-27T13:10:17Z</dc:date>
    </item>
    <item>
      <title>Re: Re querying a table using ONE Select</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/re-querying-a-table-using-one-select/m-p/8184654#M1624616</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ricky,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please try co-related subquery as below. I've not checked the exact syntax, but I'm sure this approach would fulfill your requirement in one SQL statement:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
SELECT vertrag vkonto 
INTO TABLE it_ever
FROM ever
WHERE ainzdat IN s_moveout
AND vkonto IN ( SELECT vkont
                FROM fkkvkp 
                WHERE vkont = ever~vkonto )
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here the sub-query need not have a work-area or target internal table but co-relates to the result of the parent SQL query - which exactly meets your required resultset in table IT_EVER.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Suresh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 27 Aug 2011 16:02:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/re-querying-a-table-using-one-select/m-p/8184654#M1624616</guid>
      <dc:creator>SureshRa</dc:creator>
      <dc:date>2011-08-27T16:02:57Z</dc:date>
    </item>
  </channel>
</rss>

