<?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: Problems with select statement in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/problems-with-select-statement/m-p/1436701#M208128</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;is it solved? Use FOR ALL ENTRIES option.automatically it will besolaved&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 20 Jun 2006 09:18:10 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2006-06-20T09:18:10Z</dc:date>
    <item>
      <title>Problems with select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problems-with-select-statement/m-p/1436699#M208126</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;For some reason I cannot find the solution for the following problem. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have an internal table.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;Now I like to make an select over a database table, while only rows should be selected, where the key field occurs in the internal table and in case of  identical key field only the row with the lowest value in another column is selcted.&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P&gt;- internal table:&lt;/P&gt;&lt;P&gt;col1  col2  col3 &lt;/P&gt;&lt;P&gt;1     A     AA&lt;/P&gt;&lt;P&gt;2     B     AA&lt;/P&gt;&lt;P&gt;3     A     AC&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-database table:&lt;/P&gt;&lt;P&gt;col1  col2  col3 &lt;/P&gt;&lt;P&gt;1     001   CD&lt;/P&gt;&lt;P&gt;1     002   CF&lt;/P&gt;&lt;P&gt;1     003   CG&lt;/P&gt;&lt;P&gt;2     001   CD&lt;/P&gt;&lt;P&gt;2     002   CF&lt;/P&gt;&lt;P&gt;2     003   CG&lt;/P&gt;&lt;P&gt;3     002   CF&lt;/P&gt;&lt;P&gt;3     003   CG&lt;/P&gt;&lt;P&gt;4     001   CD&lt;/P&gt;&lt;P&gt;4     002   CF&lt;/P&gt;&lt;P&gt;4     003   CG&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- the selected database entries should be&lt;/P&gt;&lt;P&gt;1     001   CD&lt;/P&gt;&lt;P&gt;2     001   CD&lt;/P&gt;&lt;P&gt;3     002   CF&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;explication: &lt;/P&gt;&lt;P&gt;- entries with 4 in the first column do not occur in the internal table, so they do not appear in the selection&lt;/P&gt;&lt;P&gt;- in case of more than one entry in the database table only the one with the lowest value in column two will be selected&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you have any idea how this could be solved, I would really appreciate you help.&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;Torsten&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Jun 2006 09:04:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problems-with-select-statement/m-p/1436699#M208126</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-06-20T09:04:39Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problems-with-select-statement/m-p/1436700#M208127</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;  sort table &amp;lt;internal table&amp;gt; by &amp;lt;internal table&amp;gt;-col1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  If NOT &amp;lt;internal table&amp;gt;[] is initial.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;       Select col1 col2 col3 &lt;/P&gt;&lt;P&gt;              from &amp;lt;database table&amp;gt;&lt;/P&gt;&lt;P&gt;              into ......&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;              &amp;lt;b&amp;gt;FOR ALL ENTRIES IN TABLE&amp;lt;/b&amp;gt; &amp;lt;internal table&amp;gt;&lt;/P&gt;&lt;P&gt;              where col1 = &amp;lt;internal table&amp;gt;-col1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  Endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this will help you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Jun 2006 09:10:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problems-with-select-statement/m-p/1436700#M208127</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-06-20T09:10:28Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problems-with-select-statement/m-p/1436701#M208128</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;is it solved? Use FOR ALL ENTRIES option.automatically it will besolaved&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Jun 2006 09:18:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problems-with-select-statement/m-p/1436701#M208128</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-06-20T09:18:10Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problems-with-select-statement/m-p/1436702#M208129</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;use for all enteries in selct query and in where clause give the where condition as fieldname = itab-fieldname.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reward points if it helps&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;Gunjan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Jun 2006 09:22:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problems-with-select-statement/m-p/1436702#M208129</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-06-20T09:22:08Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problems-with-select-statement/m-p/1436703#M208130</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;sort itab1 by col1.

select col1 col2 col3 into table itab2 for all entries in  itab1 where col1 = itab1-col1.

sort itab2 by col1 col2.

loop at itab2.
  at new col1.
  clear flag.
  l_tabix = sy-tabix.
  read table itab2 index l_tabix.
  flag = 'x'.
  endat.
 if flag ne 'x'.
   delete itab2 index l_tabix.
endloop.&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Jun 2006 09:23:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problems-with-select-statement/m-p/1436703#M208130</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-06-20T09:23:59Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problems-with-select-statement/m-p/1436704#M208131</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;1) u have to select based on internal table 1&lt;/P&gt;&lt;P&gt;2) u have to filter the internal table 2 for minimum value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;select col1 col2 col3 
from &amp;lt;any table&amp;gt;
into table &amp;lt;Internal_table_final&amp;gt;
for all entries in &amp;lt;Internal_table_1&amp;gt;
where col1 = Internal_table_1-col1.

sort Internal_table_final by col1 col2.

loop at Internal_table_final.

   at new col1.
      continue.
   endat.    
   delete Internal_table_final.

endloop.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;try this&amp;lt;/b&amp;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;&amp;lt;b&amp;gt;Mark Helpful Answers&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: Manoj Gupta&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Jun 2006 09:25:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problems-with-select-statement/m-p/1436704#M208131</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-06-20T09:25:25Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problems-with-select-statement/m-p/1436705#M208132</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Torsen,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; use the foll logic...&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="--------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Select * from db_tab into r_tab where col1 = sel_col1 .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Append r_tab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endselect.&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;&lt;/P&gt;&lt;P&gt;Sort r_tab ascending by col2. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Delete Adjacent duplicates from r_tab comparing col1.&lt;/P&gt;&lt;P&gt;&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rgds,&lt;/P&gt;&lt;P&gt;Jothi.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Do Award pts for helful answers.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Jun 2006 09:30:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problems-with-select-statement/m-p/1436705#M208132</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-06-20T09:30:48Z</dc:date>
    </item>
  </channel>
</rss>

