<?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 Lists in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-lists/m-p/1357319#M178110</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;using sort command u can sort the WA in particular &lt;/P&gt;&lt;P&gt;field&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 12 Jun 2006 09:03:44 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2006-06-12T09:03:44Z</dc:date>
    <item>
      <title>Sorting Lists</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-lists/m-p/1357315#M178106</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Gday,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am selecting from a table into the WA, then want to display the selected rows but sorted in a particular way.  Is it possible to order rows as I select them, or do I have to select them into an itab so i can order them?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Jun 2006 08:59:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-lists/m-p/1357315#M178106</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-06-12T08:59:21Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting Lists</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-lists/m-p/1357316#M178107</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;Sure you can using the ORDER BY clause in the select. However, for performance reasons it would be better to select all records in an internal table and then perform the sort.&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;&lt;/P&gt;&lt;P&gt;John.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Jun 2006 09:01:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-lists/m-p/1357316#M178107</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-06-12T09:01:05Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting Lists</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-lists/m-p/1357317#M178108</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;chk this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA: wa_sflight TYPE sflight. 

SELECT * FROM sflight INTO wa_sflight 
         WHERE carrid = 'LH' AND 
               fldate BETWEEN '20010227' AND '20010305' 
         ORDER BY planetype ASCENDING seatsocc DESCENDING. 
  WRITE: / wa_sflight-planetype, wa_sflight-seatsocc, 
           wa_sflight-connid, wa_sflight-fldate. 
ENDSELECT.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Jun 2006 09:02:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-lists/m-p/1357317#M178108</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-06-12T09:02:38Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting Lists</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-lists/m-p/1357318#M178109</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can use the 'ORDER BY' clause in the SELECT statement. F1 help on SELECT should help you with the syntax.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT * FROM SBOOK INTO WA_SBOOK
         WHERE
           CARRID  = 'LH '      AND
           CONNID  = '0400'     AND
           FLDATE  = '19950228'
         ORDER BY PRIMARY KEY.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Sudha&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Jun 2006 09:03:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-lists/m-p/1357318#M178109</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-06-12T09:03:31Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting Lists</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-lists/m-p/1357319#M178110</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;using sort command u can sort the WA in particular &lt;/P&gt;&lt;P&gt;field&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Jun 2006 09:03:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-lists/m-p/1357319#M178110</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-06-12T09:03:44Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting Lists</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-lists/m-p/1357320#M178111</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;chk this help of SELECT&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ORDER BY Clause &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Variants: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. ... ORDER BY PRIMARY KEY &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. ... ORDER BY f1 ... fn &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3. ... ORDER BY (source_text) &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Effect &lt;/P&gt;&lt;P&gt;Orders the records in a SELECT statement. Without the ORDER-BY clause, the order in which the selected lines are supplied is undefined. This means that two similar SELECT statements may produce lines in a different order. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Variant 1 &lt;/P&gt;&lt;P&gt;...ORDER BY PRIMARY KEY &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Effect &lt;/P&gt;&lt;P&gt;Sorts the selected lines in ascending order by the primary key of the database table. This variant is only permitted for SELECT * .... &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example &lt;/P&gt;&lt;P&gt;Output the passenger list for the Lufthansa flight 0400 on 28.02.2001: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: wa_sbook TYPE sbook. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT * FROM sbook INTO wa_sbook &lt;/P&gt;&lt;P&gt;         WHERE &lt;/P&gt;&lt;P&gt;           carrid   = 'LH '      AND &lt;/P&gt;&lt;P&gt;           connid   = '0400'     AND &lt;/P&gt;&lt;P&gt;           fldate   = '20010228' &lt;/P&gt;&lt;P&gt;         ORDER BY PRIMARY KEY. &lt;/P&gt;&lt;P&gt;  WRITE: / wa_sbook-bookid,     wa_sbook-customid, &lt;/P&gt;&lt;P&gt;           wa_sbook-custtype,   wa_sbook-smoker, &lt;/P&gt;&lt;P&gt;           wa_sbook-luggweight, wa_sbook-wunit, &lt;/P&gt;&lt;P&gt;           wa_sbook-invoice. &lt;/P&gt;&lt;P&gt;ENDSELECT. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Notes &lt;/P&gt;&lt;P&gt;Since views do not have a primary key, specifying ORDER BY PRIMARY KEY only makes sense with database tables. If, however, you do specify ORDER BY PRIMARY KEY with a view, all fields of the view are sorted in ascending order. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Variant 2 &lt;/P&gt;&lt;P&gt;ORDER BY f1 ... fn &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Effect &lt;/P&gt;&lt;P&gt;Sorts the selected records in ascending order by the specified column references f1 ... fn. If a list is also specified in the SELECT clause, the column references f1, ..., fn must appear in this list. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;By supplementing the statement with DESCENDING, you can sort in descending order using any of the fields f1, ..., fn. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The default sort sequence is ascending order, but you can make this explicit by adding the addition ASCENDING. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Examples &lt;/P&gt;&lt;P&gt;Output Lufthansa flights from 27.02.2001 to 05.03.2001, sorted by plane type and number of occupied seats: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: wa_sflight TYPE sflight. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT * FROM sflight INTO wa_sflight &lt;/P&gt;&lt;P&gt;         WHERE carrid = 'LH' AND &lt;/P&gt;&lt;P&gt;               fldate BETWEEN '20010227' AND '20010305' &lt;/P&gt;&lt;P&gt;         ORDER BY planetype ASCENDING seatsocc DESCENDING. &lt;/P&gt;&lt;P&gt;  WRITE: / wa_sflight-planetype, wa_sflight-seatsocc, &lt;/P&gt;&lt;P&gt;           wa_sflight-connid, wa_sflight-fldate. &lt;/P&gt;&lt;P&gt;ENDSELECT. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Notes &lt;/P&gt;&lt;P&gt;Pooled and cluster tables can only be sorted by their primary key. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;With a SELECT * ..., the client field automatically becomes the first sort criterion in client-specific tables, unless the addition CLIENT SPECIFIED is specified in the FROM clause. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Specifying FOR ALL ENTRIES IN itab WHERE ... in the WHERE clause excludes ORDER BY f1 ... fn. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The columns f1, ..., fn must not be of the type STRING or RAWSTRING. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Notes &lt;/P&gt;&lt;P&gt;Performance: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In contrast to ... ORDER BY PRIMARY KEY, ORDER BY f1 ... fn is not automatically supported by a (sorted) index. Without an index, you must sort the result set at runtime. Because of the SAP architecture, this should not be performed on the database server, but on the applications server. If it does not make sense to create an index, you should not sort the result set with ... ORDER BY f1 ... fn on the database server, but with SORT on the application server. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;With larger datasets, you should only use the variant ORDER BY f1 ... fn if the order of the database fields f1 ... fn is exactly the same as the order of one of the indexes. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Variant 3 &lt;/P&gt;&lt;P&gt;... ORDER BY (source_text) &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Effect &lt;/P&gt;&lt;P&gt;Works like ORDER BY f1 ... fn if the variable source_text contains the list f1 ... fn as ABAP source text. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note &lt;/P&gt;&lt;P&gt;The same restrictions apply to this variant as to ORDER BY f1 ... fn. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example &lt;/P&gt;&lt;P&gt;After you enter 'cityfrom' or 'cityto', the system outputs all departure or destination cities of Lufthansa, including the number of destinations. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PARAMETERS: comp(80). &lt;/P&gt;&lt;P&gt;DATA:   dref TYPE REF TO DATA, &lt;/P&gt;&lt;P&gt;        long_name TYPE STRING, &lt;/P&gt;&lt;P&gt;        name TYPE STRING, &lt;/P&gt;&lt;P&gt;        ftab TYPE TABLE OF STRING, &lt;/P&gt;&lt;P&gt;        count TYPE I. &lt;/P&gt;&lt;P&gt;FIELD-SYMBOLS: &amp;lt;fs&amp;gt;. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;name = 'SPFLI'. &lt;/P&gt;&lt;P&gt;CONCATENATE name '-' comp INTO long_name. &lt;/P&gt;&lt;P&gt;CREATE DATA dref TYPE (long_name). &lt;/P&gt;&lt;P&gt;ASSIGN dref-&amp;gt;* TO &amp;lt;fs&amp;gt;. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;APPEND comp TO ftab. &lt;/P&gt;&lt;P&gt;APPEND 'COUNT( * ) AS COUNT' TO ftab. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT DISTINCT (ftab) &lt;/P&gt;&lt;P&gt;       INTO (&amp;lt;fs&amp;gt;, count) &lt;/P&gt;&lt;P&gt;       FROM (name) &lt;/P&gt;&lt;P&gt;       WHERE &lt;/P&gt;&lt;P&gt;         carrid   = 'LH' &lt;/P&gt;&lt;P&gt;       GROUP BY (comp) &lt;/P&gt;&lt;P&gt;       ORDER BY (comp). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  WRITE: / &amp;lt;fs&amp;gt;, count. &lt;/P&gt;&lt;P&gt;ENDSELECT. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Additional help &lt;/P&gt;&lt;P&gt;Specifying a Sort Sequence&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Jun 2006 09:04:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-lists/m-p/1357320#M178111</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-06-12T09:04:20Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting Lists</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-lists/m-p/1357321#M178112</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am trying to sort by sbook-name, this is my code and doe snot seem to work&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Select * from sbook&lt;/P&gt;&lt;P&gt;where&lt;/P&gt;&lt;P&gt;  connid = sflight-connid and&lt;/P&gt;&lt;P&gt;  carrid = sflight-carrid and&lt;/P&gt;&lt;P&gt;  fldate = sflight-fldate.&lt;/P&gt;&lt;P&gt;    order by sbook-name.&lt;/P&gt;&lt;P&gt;    select single * from scustom&lt;/P&gt;&lt;P&gt;    where id = sbook-customid.&lt;/P&gt;&lt;P&gt;    &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;write:/ sbook-bookid, 18 sbook-customid, 40 scustom-name.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endselect.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Jun 2006 09:05:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-lists/m-p/1357321#M178112</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-06-12T09:05:46Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting Lists</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-lists/m-p/1357322#M178113</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;try this , change the one in bold&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;Select * from sbook
where
connid = sflight-connid and
carrid = sflight-carrid and
fldate = sflight-fldate.
&amp;lt;b&amp;gt;order by name.&amp;lt;/b&amp;gt;
select single * from scustom
where id = sbook-customid.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: Chandrasekhar Jagarlamudi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Jun 2006 09:07:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-lists/m-p/1357322#M178113</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-06-12T09:07:47Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting Lists</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-lists/m-p/1357323#M178114</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Select * from sbook&lt;/P&gt;&lt;P&gt;where&lt;/P&gt;&lt;P&gt;connid = sflight-connid and&lt;/P&gt;&lt;P&gt;carrid = sflight-carrid and&lt;/P&gt;&lt;P&gt;fldate = sflight-fldate.&lt;/P&gt;&lt;P&gt;order by &amp;lt;b&amp;gt;name&amp;lt;/b&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You do not need to specify the field name as sbook-name.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sudha&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Jun 2006 09:08:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-lists/m-p/1357323#M178114</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-06-12T09:08:42Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting Lists</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-lists/m-p/1357324#M178115</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;even SELECT allows us to specify sorting order, but we should NOT do that, because of performance reasons. it takes time to sort the data. instead you select all your records to ur internal table by SELECT &amp;amp; then use &lt;/P&gt;&lt;P&gt;SORT ITAB BY &amp;lt;FIELD1&amp;gt; &amp;lt;FIELD2&amp;gt; ASCENDING/DESCENDING.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Srikanth.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Jun 2006 09:11:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-lists/m-p/1357324#M178115</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-06-12T09:11:36Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting Lists</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-lists/m-p/1357325#M178116</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have changed to code to as suggested, however i think because it is a nested select, i am getting and error: Statement "ORDER" is not defined. Check your spelling.		&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Select * from sbook&lt;/P&gt;&lt;P&gt;where&lt;/P&gt;&lt;P&gt;  connid = sflight-connid and&lt;/P&gt;&lt;P&gt;  carrid = sflight-carrid and&lt;/P&gt;&lt;P&gt;  fldate = sflight-fldate.&lt;/P&gt;&lt;P&gt;    order by name.&lt;/P&gt;&lt;P&gt;    select single * from scustom&lt;/P&gt;&lt;P&gt;    where id = sbook-customid.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;write:...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endselect.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Jun 2006 09:12:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-lists/m-p/1357325#M178116</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-06-12T09:12:06Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting Lists</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-lists/m-p/1357326#M178117</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;before order by name there is a full stop , pls remove that&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Select * from sbook&lt;/P&gt;&lt;P&gt;where&lt;/P&gt;&lt;P&gt;connid = sflight-connid and&lt;/P&gt;&lt;P&gt;carrid = sflight-carrid and&lt;/P&gt;&lt;P&gt;fldate = sflight-fldate    &amp;lt;b&amp;gt;"remove full stop in this line&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;order by name.&lt;/P&gt;&lt;P&gt;select single * from scustom&lt;/P&gt;&lt;P&gt;where id = sbook-customid.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Jun 2006 09:14:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-lists/m-p/1357326#M178117</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-06-12T09:14:10Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting Lists</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-lists/m-p/1357327#M178118</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;nope still does not work, the field name actually comes from the single selection from scustom table?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;code now..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Select * from sbook&lt;/P&gt;&lt;P&gt;where&lt;/P&gt;&lt;P&gt;  connid = sflight-connid and&lt;/P&gt;&lt;P&gt;  carrid = sflight-carrid and&lt;/P&gt;&lt;P&gt;  fldate = sflight-fldate.&lt;/P&gt;&lt;P&gt;    select single * from scustom&lt;/P&gt;&lt;P&gt;    where id = sbook-customid&lt;/P&gt;&lt;P&gt;    order by name.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Jun 2006 09:18:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-lists/m-p/1357327#M178118</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-06-12T09:18:00Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting Lists</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-lists/m-p/1357328#M178119</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 believe,we can use ORDER BY if we are fetching large no of records into an internal table. i dont think its worth in selecting records 1 by 1 using select &amp;amp; endselect.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for performance reasons, you should not use NESTED SELECTS. instead use for all entries which will be faster.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;srikanth&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Jun 2006 09:25:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-lists/m-p/1357328#M178119</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-06-12T09:25:42Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting Lists</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-lists/m-p/1357329#M178120</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Select * from sbook&lt;/P&gt;&lt;P&gt;where&lt;/P&gt;&lt;P&gt;connid = sflight-connid and&lt;/P&gt;&lt;P&gt;carrid = sflight-carrid and&lt;/P&gt;&lt;P&gt;fldate = sflight-fldate.&lt;/P&gt;&lt;P&gt;order by name.&lt;/P&gt;&lt;P&gt;select single * from scustom&lt;/P&gt;&lt;P&gt;where id = sbook-customid.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;write:...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endselect.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;instead of above 2 selects we can write :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Select field1 &lt;/P&gt;&lt;P&gt;       field2 from sbook &lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;       into table it_sbook&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;       where connid = sflight-connid and&lt;/P&gt;&lt;P&gt;             carrid = sflight-carrid and&lt;/P&gt;&lt;P&gt;             fldate = sflight-fldate.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select  * from scustom&lt;/P&gt;&lt;P&gt;           into table it_scustom&lt;/P&gt;&lt;P&gt;           for all entries in it_sbook&lt;/P&gt;&lt;P&gt;           where id = it_sbook-customid.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;now you have print these values.&lt;/P&gt;&lt;P&gt;so &lt;/P&gt;&lt;P&gt;LOOP AT it_sbook.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  READ TABLE IT_SCUSTOM WITH KEY ID = it_sbook-CUSTOMID.&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;*--use READ table,instead of select single.&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;  IF SY-SUBRC = 0.&lt;/P&gt;&lt;P&gt;    WRITE &lt;span class="lia-unicode-emoji" title=":confused_face:"&gt;😕&lt;/span&gt;&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Jun 2006 09:31:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-lists/m-p/1357329#M178120</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-06-12T09:31:28Z</dc:date>
    </item>
  </channel>
</rss>

