<?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: Sorting problem while code is the same in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-problem-while-code-is-the-same/m-p/12143318#M1976232</link>
    <description>&lt;P&gt;From the problem raised it is not clear this is a SQL select order issue or internal table sorting issue.&lt;BR /&gt;When looping over an internal table the order of records is random. Just as is the case for a SQL select. For internal table that can be solved by using or creating a (secondary) key and using that key when looping over the table. The Excel line number should then be a part of that table key.&lt;/P&gt;</description>
    <pubDate>Wed, 04 Mar 2020 04:32:07 GMT</pubDate>
    <dc:creator>JackGraus</dc:creator>
    <dc:date>2020-03-04T04:32:07Z</dc:date>
    <item>
      <title>Sorting problem while code is the same</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-problem-while-code-is-the-same/m-p/12143301#M1976215</link>
      <description>&lt;P&gt;I have written the same program in two systems,&lt;/P&gt;
  &lt;P&gt;the code is identically the same ,but when I download the file(excel) ,&lt;STRONG&gt;both data is the same&lt;/STRONG&gt; but one is sorted differently from the other...IDK why!&lt;/P&gt;
  &lt;P&gt;&lt;STRONG&gt;Does SAP have a sorting parameter in the system,that differentiates from one system to the other?&lt;/STRONG&gt;&lt;/P&gt;
  &lt;P&gt;&lt;STRONG&gt;Please let me know if you too have encauntered this problem before!&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Feb 2020 09:04:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-problem-while-code-is-the-same/m-p/12143301#M1976215</guid>
      <dc:creator>former_member2492</dc:creator>
      <dc:date>2020-02-28T09:04:39Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting problem while code is the same</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-problem-while-code-is-the-same/m-p/12143302#M1976216</link>
      <description>&lt;P&gt;The Hana database (and apparently most of the database) does not make a default SORT in the SELECT statement,&lt;/P&gt;&lt;P&gt;So you have to add to all your SELECT statements: ORDER BY PRIMARY KEY&lt;/P&gt;&lt;P&gt;you could have issu if you do not have the fields of the key specified in the selected field. In this case you have to specify the list of the key field present in the selected fields.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Feb 2020 09:18:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-problem-while-code-is-the-same/m-p/12143302#M1976216</guid>
      <dc:creator>FredericGirod</dc:creator>
      <dc:date>2020-02-28T09:18:10Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting problem while code is the same</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-problem-while-code-is-the-same/m-p/12143303#M1976217</link>
      <description>&lt;P&gt;Are both or one of your systems on HANA?&lt;/P&gt;</description>
      <pubDate>Fri, 28 Feb 2020 09:25:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-problem-while-code-is-the-same/m-p/12143303#M1976217</guid>
      <dc:creator>Sathya_Gunasekaran</dc:creator>
      <dc:date>2020-02-28T09:25:05Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting problem while code is the same</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-problem-while-code-is-the-same/m-p/12143304#M1976218</link>
      <description>&lt;P&gt;  &lt;SPAN class="mention-scrubbed"&gt;sathya.gunasekaran3&lt;/SPAN&gt; even if the both are in Hana, the result will be different, Even between Dev / Qual &amp;amp; PROD, if you do not manage the ORDER, you could have not reproductible error between systems&lt;/P&gt;</description>
      <pubDate>Fri, 28 Feb 2020 09:33:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-problem-while-code-is-the-same/m-p/12143304#M1976218</guid>
      <dc:creator>FredericGirod</dc:creator>
      <dc:date>2020-02-28T09:33:24Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting problem while code is the same</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-problem-while-code-is-the-same/m-p/12143305#M1976219</link>
      <description>&lt;P&gt;&lt;STRONG&gt;Dear users one system is development and the other is sandbox  &lt;SPAN class="mention-scrubbed"&gt;frdric.girod&lt;/SPAN&gt;  &lt;/STRONG&gt;&lt;SPAN class="mention-scrubbed"&gt;sathya.gunasekaran6&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Feb 2020 09:35:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-problem-while-code-is-the-same/m-p/12143305#M1976219</guid>
      <dc:creator>former_member2492</dc:creator>
      <dc:date>2020-02-28T09:35:12Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting problem while code is the same</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-problem-while-code-is-the-same/m-p/12143306#M1976220</link>
      <description>&lt;P&gt;Dear user one system is development and the other is sandbox,is this still related? &lt;/P&gt;</description>
      <pubDate>Fri, 28 Feb 2020 09:35:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-problem-while-code-is-the-same/m-p/12143306#M1976220</guid>
      <dc:creator>former_member2492</dc:creator>
      <dc:date>2020-02-28T09:35:42Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting problem while code is the same</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-problem-while-code-is-the-same/m-p/12143307#M1976221</link>
      <description>&lt;P&gt;try after updating your code &lt;/P&gt;</description>
      <pubDate>Fri, 28 Feb 2020 09:37:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-problem-while-code-is-the-same/m-p/12143307#M1976221</guid>
      <dc:creator>FredericGirod</dc:creator>
      <dc:date>2020-02-28T09:37:23Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting problem while code is the same</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-problem-while-code-is-the-same/m-p/12143308#M1976222</link>
      <description>&lt;P&gt; &lt;SPAN class="mention-scrubbed"&gt;frdric.girod&lt;/SPAN&gt; , Yes I understand thats why I asked are both or one of their systems on HANA &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Feb 2020 09:38:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-problem-while-code-is-the-same/m-p/12143308#M1976222</guid>
      <dc:creator>Sathya_Gunasekaran</dc:creator>
      <dc:date>2020-02-28T09:38:06Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting problem while code is the same</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-problem-while-code-is-the-same/m-p/12143309#M1976223</link>
      <description>&lt;P&gt;  &lt;SPAN class="mention-scrubbed"&gt;johnu951&lt;/SPAN&gt; - What is your DB?&lt;/P&gt;</description>
      <pubDate>Fri, 28 Feb 2020 09:39:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-problem-while-code-is-the-same/m-p/12143309#M1976223</guid>
      <dc:creator>Sathya_Gunasekaran</dc:creator>
      <dc:date>2020-02-28T09:39:23Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting problem while code is the same</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-problem-while-code-is-the-same/m-p/12143310#M1976224</link>
      <description>&lt;P&gt;&lt;STRONG&gt;Any&lt;/STRONG&gt; relational database management system does not guarantee you a sorted order (by for example the primary key) with a select statement, if you &lt;STRONG&gt;don’t request&lt;/STRONG&gt; a sort order.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Even if it „works“ a hundred times, it is not guaranteed. &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;You either have to assign a sort order to the select statement or sort your internal table manually, or define your internal table with type SORTED.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Feb 2020 12:20:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-problem-while-code-is-the-same/m-p/12143310#M1976224</guid>
      <dc:creator>michael_piesche</dc:creator>
      <dc:date>2020-02-28T12:20:49Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting problem while code is the same</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-problem-while-code-is-the-same/m-p/12143311#M1976225</link>
      <description>&lt;P&gt;&lt;A href="https://answers.sap.com/users/60283/sathya.gunasekaran6.html"&gt;Sathya Gunasekaran&lt;/A&gt; So, if you understand, why do you care about the database systems? That's not relevant for the question. It's probably just a SQL question here. (or does HANA introduces an automatic sort order, just for the pleasure to provide a non-standard SQL?)&lt;/P&gt;</description>
      <pubDate>Fri, 28 Feb 2020 13:05:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-problem-while-code-is-the-same/m-p/12143311#M1976225</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2020-02-28T13:05:42Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting problem while code is the same</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-problem-while-code-is-the-same/m-p/12143312#M1976226</link>
      <description>&lt;P&gt;  &lt;SPAN class="mention-scrubbed"&gt;sandra.rossi&lt;/SPAN&gt; : Before saying that the addition of explicit orderby to the SQL will solve the problem, I wanted to make sure the db was HANA&lt;/P&gt;</description>
      <pubDate>Fri, 28 Feb 2020 13:51:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-problem-while-code-is-the-same/m-p/12143312#M1976226</guid>
      <dc:creator>Sathya_Gunasekaran</dc:creator>
      <dc:date>2020-02-28T13:51:40Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting problem while code is the same</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-problem-while-code-is-the-same/m-p/12143313#M1976227</link>
      <description>&lt;P&gt;I am in testing,once confirmed I will accept the answer.&lt;/P&gt;</description>
      <pubDate>Tue, 03 Mar 2020 08:35:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-problem-while-code-is-the-same/m-p/12143313#M1976227</guid>
      <dc:creator>former_member2492</dc:creator>
      <dc:date>2020-03-03T08:35:50Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting problem while code is the same</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-problem-while-code-is-the-same/m-p/12143314#M1976228</link>
      <description>&lt;P&gt;I am in testing,once confirmed I will accept the answer.&lt;/P&gt;</description>
      <pubDate>Tue, 03 Mar 2020 08:35:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-problem-while-code-is-the-same/m-p/12143314#M1976228</guid>
      <dc:creator>former_member2492</dc:creator>
      <dc:date>2020-03-03T08:35:58Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting problem while code is the same</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-problem-while-code-is-the-same/m-p/12143315#M1976229</link>
      <description>&lt;P&gt;Dear programmers. Please understand that &lt;STRONG&gt;there is no defined order on an referential database&lt;/STRONG&gt;. Whether Oracle, ADABAS, Informix or HANA.&lt;/P&gt;&lt;P&gt;There &lt;EM&gt;never &lt;/EM&gt;has been. &lt;/P&gt;&lt;P&gt;If you do not specify ORDER BY, the result set order is simply not defined. Experimentally, you may find they're in primary key order, but I've explicitly seen it on an Oracle database where this wasn't the case and the code &lt;STRONG&gt;broke&lt;/STRONG&gt;.&lt;/P&gt;</description>
      <pubDate>Tue, 03 Mar 2020 10:31:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-problem-while-code-is-the-same/m-p/12143315#M1976229</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2020-03-03T10:31:15Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting problem while code is the same</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-problem-while-code-is-the-same/m-p/12143316#M1976230</link>
      <description>&lt;P&gt;Thank Michael. I was beginning to think it was only me who understood this!&lt;/P&gt;</description>
      <pubDate>Tue, 03 Mar 2020 10:32:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-problem-while-code-is-the-same/m-p/12143316#M1976230</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2020-03-03T10:32:03Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting problem while code is the same</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-problem-while-code-is-the-same/m-p/12143317#M1976231</link>
      <description>&lt;P&gt;  &lt;SPAN class="mention-scrubbed"&gt;johnu951&lt;/SPAN&gt;, if you ever had classes on RDBMS and SQL, that is one of the first things you get to learn, that an order is only established by the ORDER BY clause and otherwise it is 'random'. &lt;/P&gt;&lt;P&gt;Developers like to be lazy, so trust me, I would love to avoid making sure of a sort order if I could rely on a database select to do that for me. But it has to do it "EVERY TIME" for me, if i have to rely on it, otherwise I have constructed coding that has a bug. &lt;/P&gt;&lt;P&gt;I have actually encountered it in a system where a simple select didnt return the values in a sorted order of the primary key. The reasons for this can be ABAP (e.g. a partially buffered table) or also settings in the RDBMS in general or for the specific db or because of its size. You would need to dig really deep in those cases to find out why it is not sorted by key "like it always" is.&lt;/P&gt;&lt;P&gt;Is all that really worth the time being spent on? But I guess everybody has to experience this for themselves in order to believe it, I did too, even though I should have known better &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Mar 2020 12:50:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-problem-while-code-is-the-same/m-p/12143317#M1976231</guid>
      <dc:creator>michael_piesche</dc:creator>
      <dc:date>2020-03-03T12:50:42Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting problem while code is the same</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-problem-while-code-is-the-same/m-p/12143318#M1976232</link>
      <description>&lt;P&gt;From the problem raised it is not clear this is a SQL select order issue or internal table sorting issue.&lt;BR /&gt;When looping over an internal table the order of records is random. Just as is the case for a SQL select. For internal table that can be solved by using or creating a (secondary) key and using that key when looping over the table. The Excel line number should then be a part of that table key.&lt;/P&gt;</description>
      <pubDate>Wed, 04 Mar 2020 04:32:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-problem-while-code-is-the-same/m-p/12143318#M1976232</guid>
      <dc:creator>JackGraus</dc:creator>
      <dc:date>2020-03-04T04:32:07Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting problem while code is the same</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-problem-while-code-is-the-same/m-p/12143319#M1976233</link>
      <description>&lt;P&gt;&lt;SPAN class="mention-scrubbed"&gt;johnu951&lt;/SPAN&gt;, please follow up on your open question.&lt;/P&gt;&lt;UL&gt;
&lt;LI&gt;comment answers or your question if there are still open issues.&lt;/LI&gt;&lt;LI&gt;otherwise mark an answer as accepted if it helped you solve your problem&lt;/LI&gt;&lt;LI&gt;or post an answer of yourself and accept it if you found another useful solution yourself&lt;/LI&gt;&lt;LI&gt;or redirect your question to another question that is related and was useful to solve your problem&lt;/LI&gt;&lt;LI&gt;in the end, close your question&lt;/LI&gt;&lt;/UL&gt;</description>
      <pubDate>Wed, 13 May 2020 13:35:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-problem-while-code-is-the-same/m-p/12143319#M1976233</guid>
      <dc:creator>michael_piesche</dc:creator>
      <dc:date>2020-05-13T13:35:41Z</dc:date>
    </item>
  </channel>
</rss>

