<?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 Select order by in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-order-by/m-p/5791619#M1310008</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have an issue:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I Know the aggregate function ORDER BY and I know we can specify the columns we need to put in order and if they have to be ASCENDING or DESCENDING&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But I'd like to create a "personal criterium", for example i have the rseg table and the field KSCHL, i want to order this field this way:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;KSCHL = ''&lt;/P&gt;&lt;P&gt;KSCHL = FRA1' &lt;/P&gt;&lt;P&gt;KSCHL = 'FRB1' &lt;/P&gt;&lt;P&gt;KSCHL = 'ZK02'&lt;/P&gt;&lt;P&gt;KSCHL = 'ZK05' &lt;/P&gt;&lt;P&gt;KSCHL = 'ZFR2' &lt;/P&gt;&lt;P&gt;KSCHL = 'ZIIP' &lt;/P&gt;&lt;P&gt;KSCHL = 'ZII'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I mean if I put DESCENDING or ASCENDING it won't be like this, but i need these last two types to be in the final and the type '' first.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How can i achieve this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in Advance!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 17 Jun 2009 13:35:11 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2009-06-17T13:35:11Z</dc:date>
    <item>
      <title>Select order by</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-order-by/m-p/5791619#M1310008</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have an issue:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I Know the aggregate function ORDER BY and I know we can specify the columns we need to put in order and if they have to be ASCENDING or DESCENDING&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But I'd like to create a "personal criterium", for example i have the rseg table and the field KSCHL, i want to order this field this way:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;KSCHL = ''&lt;/P&gt;&lt;P&gt;KSCHL = FRA1' &lt;/P&gt;&lt;P&gt;KSCHL = 'FRB1' &lt;/P&gt;&lt;P&gt;KSCHL = 'ZK02'&lt;/P&gt;&lt;P&gt;KSCHL = 'ZK05' &lt;/P&gt;&lt;P&gt;KSCHL = 'ZFR2' &lt;/P&gt;&lt;P&gt;KSCHL = 'ZIIP' &lt;/P&gt;&lt;P&gt;KSCHL = 'ZII'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I mean if I put DESCENDING or ASCENDING it won't be like this, but i need these last two types to be in the final and the type '' first.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How can i achieve this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in Advance!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Jun 2009 13:35:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-order-by/m-p/5791619#M1310008</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-06-17T13:35:11Z</dc:date>
    </item>
    <item>
      <title>Re: Select order by</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-order-by/m-p/5791620#M1310009</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;By the time of SELECT query using the ORDER BY clause you can have only any of the below options.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. Using the primary key fields.&lt;/P&gt;&lt;P&gt;2. Using the field names, i.e. FIELD1 ASCENDING FIELD2 DESCENDING etc.. kind of addition.&lt;/P&gt;&lt;P&gt;3. Defining the our own sort criteria.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For fulfilling your requirement, it is not possible by using any of the available options.&lt;/P&gt;&lt;P&gt;The only way is to read the internal table with the required key using the binary key option and then appending it into another internal table etc.. kind of stuff is required.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Santhosh.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Jun 2009 14:02:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-order-by/m-p/5791620#M1310009</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-06-17T14:02:43Z</dc:date>
    </item>
    <item>
      <title>Re: Select order by</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-order-by/m-p/5791621#M1310010</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello, thanks for your answer&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I had an idea? Don't you think a subquery would work??&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'll try it here, if i succeed I post!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks once again!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Jun 2009 14:37:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-order-by/m-p/5791621#M1310010</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-06-17T14:37:55Z</dc:date>
    </item>
    <item>
      <title>Re: Select order by</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-order-by/m-p/5791622#M1310011</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I dont think so...that you can specify it in select statement....i.e. your own criteria..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However what you can do is...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Once you have the data in an internal table ....you need to loop it and transfer the data in another internal table which has one more field may be SORT_POSN...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
e.g. select*
      from dtable into gt_table.

LOOP AT gt_table INTO gs_table.
IF gs_table-kschl = ''.
    gs_final-SORRT_POSN = '1'.
* Move all the other data from gs_Table into gs_final.
APPEND gs_final TO gt_final.
ENDIF.

IF gs_table-kschl = 'FRA1'.
    gs_final-SORRT_POSN = '2'.
* Move all the other data from gs_Table into gs_final.
APPEND gs_final TO gt_final.
ENDIF.

IF gs_table-kschl = 'FRB1'.
    gs_final-SORRT_POSN = '3'.
* Move all the other data from gs_Table into gs_final.
APPEND gs_final TO gt_final.
ENDIF.

* Similarly do it for all other sort criterian...
ENDLOOP.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now you have all the data in GT_FINAL..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;All you have to do now is, sort the internal table GT_FINAL BY SORT_POSN.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope it helps!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Jun 2009 14:42:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-order-by/m-p/5791622#M1310011</guid>
      <dc:creator>former_member212005</dc:creator>
      <dc:date>2009-06-17T14:42:46Z</dc:date>
    </item>
    <item>
      <title>Re: Select order by</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-order-by/m-p/5791623#M1310012</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ok, thank you very much! I got your idea!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;but I'm trying to save time because I'm dealing with too much data  and this code will take a lot of time in the program...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks anyway&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Jun 2009 14:54:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-order-by/m-p/5791623#M1310012</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-06-17T14:54:58Z</dc:date>
    </item>
  </channel>
</rss>

