<?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: Incorrect sort sequence while fetching from Database in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/incorrect-sort-sequence-while-fetching-from-database/m-p/7916049#M1598196</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Matt,&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; This is in continuation to my above question. Now i see that even in SE11 when i give maximum number of records as 100 it fetches me different records and when i give it as 200 it fetches me different. To be more clear see the below example.&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; i have sales orders 1 - 65000.&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; when i give 100 as maximum number it fetches records 1-95 and remaining 5 records are 64,001 to 64,005.&lt;/P&gt;&lt;P&gt;&amp;gt; when i give 200 as maximum number it fetches records 1-195 and remaining 5 records are 64,001 to 64,005.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;My earlier statement stands: &lt;STRONG&gt;The order in which records are returned from the database is undefined.&lt;/STRONG&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Two identical SQL calls at different times can result in different results, if you don't return the full result set. When you use the data browser, you are not guaranteed to get the same result set if you change the number of records to retrieve - or even with two calls for the same number of records.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 24 Jun 2011 13:17:55 GMT</pubDate>
    <dc:creator>matt</dc:creator>
    <dc:date>2011-06-24T13:17:55Z</dc:date>
    <item>
      <title>Incorrect sort sequence while fetching from Database</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/incorrect-sort-sequence-while-fetching-from-database/m-p/7916042#M1598189</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;When I am trying to fetch records from database table to table to internal table, the records are in jumbled sequence.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example: &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

SELECT * 
  FROM vbak 
    UP TO 100 ROWS 
  INTO TABLE itab3 
 WHERE vbeln in s_vbeln 
  AND posnr in s_posnr.
IF sy-subrc EQ 0.

ENDIF. &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The sequence what i see in SE11 is differing in internal table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Sarves&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Jun 2011 10:21:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/incorrect-sort-sequence-while-fetching-from-database/m-p/7916042#M1598189</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-06-24T10:21:39Z</dc:date>
    </item>
    <item>
      <title>Re: Incorrect sort sequence while fetching from Database</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/incorrect-sort-sequence-while-fetching-from-database/m-p/7916043#M1598190</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The order in the database is not defined. You must use ORDER BY in your SQL or sort your internal table.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Jun 2011 10:29:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/incorrect-sort-sequence-while-fetching-from-database/m-p/7916043#M1598190</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2011-06-24T10:29:39Z</dc:date>
    </item>
    <item>
      <title>Re: Incorrect sort sequence while fetching from Database</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/incorrect-sort-sequence-while-fetching-from-database/m-p/7916044#M1598191</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can order by .&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Jun 2011 10:39:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/incorrect-sort-sequence-while-fetching-from-database/m-p/7916044#M1598191</guid>
      <dc:creator>Sandeep_Panghal</dc:creator>
      <dc:date>2011-06-24T10:39:32Z</dc:date>
    </item>
    <item>
      <title>Re: Incorrect sort sequence while fetching from Database</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/incorrect-sort-sequence-while-fetching-from-database/m-p/7916045#M1598192</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Matt,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is in continuation to my above question. Now i see that even in SE11 when i give maximum number of records as 100 it fetches me different records and when i give it as 200 it fetches me different. To be more clear see the below example.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i have sales orders 1 - 65000.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;when i give 100 as maximum number it fetches records 1-95 and remaining 5 records are 64,001 to 64,005.&lt;/P&gt;&lt;P&gt;when i give 200 as maximum number it fetches records 1-195 and remaining 5 records are 64,001 to 64,005.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The Database is DB2.&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;Sarves&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Jun 2011 11:25:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/incorrect-sort-sequence-while-fetching-from-database/m-p/7916045#M1598192</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-06-24T11:25:18Z</dc:date>
    </item>
    <item>
      <title>Re: Incorrect sort sequence while fetching from Database</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/incorrect-sort-sequence-while-fetching-from-database/m-p/7916046#M1598193</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Sarves,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What you see in the data browser of SE11(or SE16) is a report output &amp;amp; not the actual DB snapshot!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BR,&lt;/P&gt;&lt;P&gt;Suhas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Jun 2011 11:34:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/incorrect-sort-sequence-while-fetching-from-database/m-p/7916046#M1598193</guid>
      <dc:creator>SuhaSaha</dc:creator>
      <dc:date>2011-06-24T11:34:55Z</dc:date>
    </item>
    <item>
      <title>Re: Incorrect sort sequence while fetching from Database</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/incorrect-sort-sequence-while-fetching-from-database/m-p/7916047#M1598194</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Sarvesh,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is because of the algoritham used by the database.&lt;/P&gt;&lt;P&gt;This search will use the DIVIDE and FETCH rule for data fetching, so some of the entries will be taken and rest will be skipped.&lt;/P&gt;&lt;P&gt;Thats the reason why you are getting a part in the select with 100 and another part with 200.&lt;/P&gt;&lt;P&gt;specifying the WHERE condition is the only possible way.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you declare the internal table as SORTED, the data that you are fetching will be the same and only thing thing is it will be as SORTED in the internal table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;HM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Jun 2011 12:18:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/incorrect-sort-sequence-while-fetching-from-database/m-p/7916047#M1598194</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-06-24T12:18:26Z</dc:date>
    </item>
    <item>
      <title>Re: Incorrect sort sequence while fetching from Database</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/incorrect-sort-sequence-while-fetching-from-database/m-p/7916048#M1598195</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;order by is expensive.  SAP recommends a simple sort by statement after db retrieval.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Jun 2011 12:24:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/incorrect-sort-sequence-while-fetching-from-database/m-p/7916048#M1598195</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-06-24T12:24:11Z</dc:date>
    </item>
    <item>
      <title>Re: Incorrect sort sequence while fetching from Database</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/incorrect-sort-sequence-while-fetching-from-database/m-p/7916049#M1598196</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Matt,&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; This is in continuation to my above question. Now i see that even in SE11 when i give maximum number of records as 100 it fetches me different records and when i give it as 200 it fetches me different. To be more clear see the below example.&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; i have sales orders 1 - 65000.&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; when i give 100 as maximum number it fetches records 1-95 and remaining 5 records are 64,001 to 64,005.&lt;/P&gt;&lt;P&gt;&amp;gt; when i give 200 as maximum number it fetches records 1-195 and remaining 5 records are 64,001 to 64,005.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;My earlier statement stands: &lt;STRONG&gt;The order in which records are returned from the database is undefined.&lt;/STRONG&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Two identical SQL calls at different times can result in different results, if you don't return the full result set. When you use the data browser, you are not guaranteed to get the same result set if you change the number of records to retrieve - or even with two calls for the same number of records.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Jun 2011 13:17:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/incorrect-sort-sequence-while-fetching-from-database/m-p/7916049#M1598196</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2011-06-24T13:17:55Z</dc:date>
    </item>
  </channel>
</rss>

