<?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 coding in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-coding/m-p/1108220#M105416</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you need more fields from the db, then just add them to the internal table...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;


data: begin of itab occurs 0, 
      userid(10) type c,     
      date type sy-datum,  
&amp;lt;b&amp;gt;      fld1(10) type c,
      fld2(10) type c,
      fld3(10) type c,&amp;lt;/b&amp;gt;
      end of itab.


Select * &amp;lt;b&amp;gt;into corresponding fields of table itab&amp;lt;/b&amp;gt; 
           from zdb           
           where   date &amp;lt;= sy-datum      
             order by date descending.

sort itab by userid ascending date descending.

delete adjacent duplicates from itab comparing userid.



&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;Rich Heilman&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 17 Oct 2005 19:20:53 GMT</pubDate>
    <dc:creator>RichHeilman</dc:creator>
    <dc:date>2005-10-17T19:20:53Z</dc:date>
    <item>
      <title>select coding</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-coding/m-p/1108210#M105406</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt; i have several entries in db as follows.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;DEL&gt;-id&lt;/DEL&gt;&lt;DEL&gt;-date&lt;/DEL&gt;---&lt;/P&gt;&lt;P&gt;10001----20060403&lt;/P&gt;&lt;P&gt;10001--&lt;DEL&gt;20050403 &amp;lt;&lt;/DEL&gt;-----&lt;/P&gt;&lt;P&gt;10001----20040403&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i need to pick the record which is less than or equal to current date and the most current one. in this case i need to pick the second record.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i DONT WANT TO USE internal table. could some one suggest a select statement on which i can proceed.&lt;/P&gt;&lt;P&gt;your help would be appreciated&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;ravi.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;rob and rich,&lt;/P&gt;&lt;P&gt; one small problem, i have several records with different id's but if i use this its working only for one id, can you suggest some modifications so that i can go ahead.its important for me to use select and endselect.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;ravi.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;rich,&lt;/P&gt;&lt;P&gt; i need one record per id with the above validations(there are several fields i need to select apart from id and date).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;ravi.&lt;/P&gt;&lt;P&gt;Message was edited by: ravi kumar&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: ravi kumar&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Oct 2005 17:44:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-coding/m-p/1108210#M105406</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-10-17T17:44:13Z</dc:date>
    </item>
    <item>
      <title>Re: select coding</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-coding/m-p/1108211#M105407</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
select ...
up to 1 rows
where date le sy-datum
order by db_date_field descending
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I changed this a bit.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: Rob Burbank&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Oct 2005 17:48:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-coding/m-p/1108211#M105407</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-10-17T17:48:07Z</dc:date>
    </item>
    <item>
      <title>Re: select coding</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-coding/m-p/1108212#M105408</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;Select Single * into structure
      from zdb
         where date &amp;lt;= sy-datum order by date.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't know if this is the correct syntax.  But I believe it will work if you use the order by extension.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Rich Heilman&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Oct 2005 17:49:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-coding/m-p/1108212#M105408</guid>
      <dc:creator>RichHeilman</dc:creator>
      <dc:date>2005-10-17T17:49:48Z</dc:date>
    </item>
    <item>
      <title>Re: select coding</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-coding/m-p/1108213#M105409</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Do you need to select for a specific id?  If so, then just add it to the WHERE clause of the select statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;Select Single * into structure     
     from zdb         
      where  userid = '1001'
         and date &amp;lt;= sy-datum 
               order by date descending.&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;Rich Heilman&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Oct 2005 19:03:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-coding/m-p/1108213#M105409</guid>
      <dc:creator>RichHeilman</dc:creator>
      <dc:date>2005-10-17T19:03:26Z</dc:date>
    </item>
    <item>
      <title>Re: select coding</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-coding/m-p/1108214#M105410</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can get rid of the "up to 1 rows", but you will select more than 1 record. So you'll probably want to use an internal table to decide which id to use.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Oct 2005 19:05:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-coding/m-p/1108214#M105410</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-10-17T19:05:15Z</dc:date>
    </item>
    <item>
      <title>Re: select coding</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-coding/m-p/1108215#M105411</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Or do  you want to get 1 record per userid.  The record which date &amp;lt;= sy-datum and the closes to today.  &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I mean is....  do you want?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;DEL&gt;-id&lt;/DEL&gt;&lt;DEL&gt;-date&lt;/DEL&gt;---&lt;/P&gt;&lt;P&gt;10001----20060403&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;10001--&lt;DEL&gt;20050403 &amp;lt;&lt;/DEL&gt;----- This&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;10001----20040403&lt;/P&gt;&lt;P&gt;10002----20060403&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;10002--&lt;DEL&gt;20050403 &amp;lt;&lt;/DEL&gt;----- And This&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;10002----20040403&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;Rich Heilman&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Oct 2005 19:06:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-coding/m-p/1108215#M105411</guid>
      <dc:creator>RichHeilman</dc:creator>
      <dc:date>2005-10-17T19:06:35Z</dc:date>
    </item>
    <item>
      <title>Re: select coding</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-coding/m-p/1108216#M105412</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you want it like this.....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;DEL&gt;-id&lt;/DEL&gt;&lt;DEL&gt;-date&lt;/DEL&gt;---&lt;/P&gt;&lt;P&gt;10001----20060403&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;10001--&lt;DEL&gt;20050403 &amp;lt;&lt;/DEL&gt;----- This&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;10001----20040403&lt;/P&gt;&lt;P&gt;10002----20060403&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;10002--&lt;DEL&gt;20050403 &amp;lt;&lt;/DEL&gt;----- And This&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;10002----20040403&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You will have to use an internal table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;data: begin of itab occurs 0,
      userid(10) type c,
      date type sy-datum,
      end of itab.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;Select * into table itab  
         from zdb            
        where      
           date &amp;lt;= sy-datum      
             order by date descending.

sort itab by userid ascending
             date   descending.

delete adjacent duplicates from itab comparing userid.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This should work for ya.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Rich Heilman&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Oct 2005 19:13:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-coding/m-p/1108216#M105412</guid>
      <dc:creator>RichHeilman</dc:creator>
      <dc:date>2005-10-17T19:13:28Z</dc:date>
    </item>
    <item>
      <title>Re: select coding</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-coding/m-p/1108217#M105413</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So do:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
select ...
where date le sy-datum
order by db_date_field descending
group by date id
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Oct 2005 19:14:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-coding/m-p/1108217#M105413</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-10-17T19:14:20Z</dc:date>
    </item>
    <item>
      <title>Re: select coding</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-coding/m-p/1108218#M105414</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Please don't change the original post, rather come back to use by posting another reply to this thread. Thanks.  My previous answer should help you.  You must use an internal table, though, because you want multiple records.  &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Rich Heilman&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Oct 2005 19:15:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-coding/m-p/1108218#M105414</guid>
      <dc:creator>RichHeilman</dc:creator>
      <dc:date>2005-10-17T19:15:36Z</dc:date>
    </item>
    <item>
      <title>Re: select coding</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-coding/m-p/1108219#M105415</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;SELECT (your_field_list_here) up to 1 rows &lt;/P&gt;&lt;P&gt;  WHERE the_date_field le sy-datum&lt;/P&gt;&lt;P&gt;  order by the_date_field descending&lt;/P&gt;&lt;P&gt;  group by id.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;your business logic here&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDSELECT.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Oct 2005 19:17:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-coding/m-p/1108219#M105415</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-10-17T19:17:32Z</dc:date>
    </item>
    <item>
      <title>Re: select coding</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-coding/m-p/1108220#M105416</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you need more fields from the db, then just add them to the internal table...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;


data: begin of itab occurs 0, 
      userid(10) type c,     
      date type sy-datum,  
&amp;lt;b&amp;gt;      fld1(10) type c,
      fld2(10) type c,
      fld3(10) type c,&amp;lt;/b&amp;gt;
      end of itab.


Select * &amp;lt;b&amp;gt;into corresponding fields of table itab&amp;lt;/b&amp;gt; 
           from zdb           
           where   date &amp;lt;= sy-datum      
             order by date descending.

sort itab by userid ascending date descending.

delete adjacent duplicates from itab comparing userid.



&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;Rich Heilman&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Oct 2005 19:20:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-coding/m-p/1108220#M105416</guid>
      <dc:creator>RichHeilman</dc:creator>
      <dc:date>2005-10-17T19:20:53Z</dc:date>
    </item>
    <item>
      <title>Re: select coding</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-coding/m-p/1108221#M105417</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;By the way,  I'm curious,  why is it important for you to use SELECT..ENDSELECT.  Why are you so against internal tables.   You know that SELECT...ENDSELECT is slower than an Array Fetch(internal table), right?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Rich Heilman&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Oct 2005 19:35:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-coding/m-p/1108221#M105417</guid>
      <dc:creator>RichHeilman</dc:creator>
      <dc:date>2005-10-17T19:35:01Z</dc:date>
    </item>
    <item>
      <title>Re: select coding</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-coding/m-p/1108222#M105418</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ravi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is your issue resolved?  If so, please reward points accordingly.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Oct 2005 01:40:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-coding/m-p/1108222#M105418</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-10-18T01:40:28Z</dc:date>
    </item>
  </channel>
</rss>

