<?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: sort itab by select-options in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/sort-itab-by-select-options/m-p/5944253#M1335115</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;First of all please avoid such a select statement. It causes a lot of performance problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Code like this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT  *  FROM MARA 
INTO CORRESPONDING FIELDS OF TABLE IT_ITAB
WHERE MATNR IN S_MATNR.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Secondly what do you mean by SORT ITAB by SELECT_OPTIONS S_MATNR.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You yourself have said that the select-option can contain single values or multiple values or ranges.&lt;/P&gt;&lt;P&gt;So how should the SORT be?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kinldy check with the requirment. It seems a little weird.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Ankur Parab&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 30 Jul 2009 07:44:44 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2009-07-30T07:44:44Z</dc:date>
    <item>
      <title>sort itab by select-options</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sort-itab-by-select-options/m-p/5944251#M1335113</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;i have this code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
*
SELECT-OPTIONS:   S_MATNR   FOR MARA-MATNR.
*
...
*
  SELECT  * FROM MARA WHERE MATNR IN S_MATNR.
*
    CLEAR: WA_ITAB.
    WA_ITAB-MATNR = MARA-MATNR.
    WA_ITAB-MTART = MARA-MTART.
    WA_ITAB-MATKL = MARA-MATKL.

*
    APPEND WA_ITAB TO IT_ITAB.
*
  ENDSELECT.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;now i want to sort the it_itab by the given select-options. Is this possible?&lt;/P&gt;&lt;P&gt;( select-options can have single valuse, ranges, meta characters)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Or is it possible to use select from table mara in order by select-options?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards, Dieter&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Jul 2009 07:36:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sort-itab-by-select-options/m-p/5944251#M1335113</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-07-30T07:36:43Z</dc:date>
    </item>
    <item>
      <title>Re: sort itab by select-options</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sort-itab-by-select-options/m-p/5944252#M1335114</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;Could you please explain the req better..&lt;/P&gt;&lt;P&gt;If i have understood that the it_tab needs to be sorted then,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SORT it_tab by matnr ascending/descending. (choose whichever u want)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Jul 2009 07:41:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sort-itab-by-select-options/m-p/5944252#M1335114</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-07-30T07:41:57Z</dc:date>
    </item>
    <item>
      <title>Re: sort itab by select-options</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sort-itab-by-select-options/m-p/5944253#M1335115</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;First of all please avoid such a select statement. It causes a lot of performance problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Code like this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT  *  FROM MARA 
INTO CORRESPONDING FIELDS OF TABLE IT_ITAB
WHERE MATNR IN S_MATNR.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Secondly what do you mean by SORT ITAB by SELECT_OPTIONS S_MATNR.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You yourself have said that the select-option can contain single values or multiple values or ranges.&lt;/P&gt;&lt;P&gt;So how should the SORT be?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kinldy check with the requirment. It seems a little weird.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Ankur Parab&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Jul 2009 07:44:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sort-itab-by-select-options/m-p/5944253#M1335115</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-07-30T07:44:44Z</dc:date>
    </item>
    <item>
      <title>Re: sort itab by select-options</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sort-itab-by-select-options/m-p/5944254#M1335116</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;select 
           MATNR 
           MTART 
           MATKL
           from MARA
           into table IT_MARA
           where MATNR in S_MATNR group by matnr.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you can either use group by MATNR.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;or after selecting you can write&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;sort it_MATA by MATNR.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Jul 2009 07:50:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sort-itab-by-select-options/m-p/5944254#M1335116</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-07-30T07:50:08Z</dc:date>
    </item>
    <item>
      <title>Re: sort itab by select-options</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sort-itab-by-select-options/m-p/5944255#M1335117</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ankur,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;when i insert this value in select-options:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;200009&lt;/P&gt;&lt;P&gt;200007&lt;/P&gt;&lt;P&gt;200001 - 200005&lt;/P&gt;&lt;P&gt;200006&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i get the it_itab in this order:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;200001&lt;/P&gt;&lt;P&gt;200002&lt;/P&gt;&lt;P&gt;200003&lt;/P&gt;&lt;P&gt;200004&lt;/P&gt;&lt;P&gt;200005&lt;/P&gt;&lt;P&gt;200006&lt;/P&gt;&lt;P&gt;200007&lt;/P&gt;&lt;P&gt;200009&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;but i want this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;200009&lt;/P&gt;&lt;P&gt;200007&lt;/P&gt;&lt;P&gt;200001&lt;/P&gt;&lt;P&gt;200002&lt;/P&gt;&lt;P&gt;200003&lt;/P&gt;&lt;P&gt;200004&lt;/P&gt;&lt;P&gt;200005&lt;/P&gt;&lt;P&gt;200006&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is this possible?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards, Dieter&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Jul 2009 07:50:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sort-itab-by-select-options/m-p/5944255#M1335117</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-07-30T07:50:41Z</dc:date>
    </item>
    <item>
      <title>Re: sort itab by select-options</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sort-itab-by-select-options/m-p/5944256#M1335118</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;No this is not possible ....  you need to round about logic to acheive.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Jul 2009 07:53:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sort-itab-by-select-options/m-p/5944256#M1335118</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-07-30T07:53:34Z</dc:date>
    </item>
    <item>
      <title>Re: sort itab by select-options</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sort-itab-by-select-options/m-p/5944257#M1335119</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;This is not achievable with the SORT statement.&lt;/P&gt;&lt;P&gt;You will have to acheive it by LOOPING on the select-options table and then reading your internal table ITAB and then appending it in other internal table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also what should be done incase the user chooses NE in the select-option or excludes some values in the range?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It really seems a weird requirement. &lt;SPAN __jive_emoticon_name="sad"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Ankur Parab&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Jul 2009 07:55:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sort-itab-by-select-options/m-p/5944257#M1335119</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-07-30T07:55:31Z</dc:date>
    </item>
    <item>
      <title>Re: sort itab by select-options</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sort-itab-by-select-options/m-p/5944258#M1335120</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try something like &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;TABLES: mara.

SELECT-OPTIONS:   s_matnr   FOR mara-matnr.

TYPES: BEGIN OF type_mara,
         matnr LIKE mara-matnr,
         mtart LIKE mara-mtart,
         matkl LIKE mara-matkl,
       END OF type_mara.

DATA: wa_itab TYPE type_mara,
      lt_itab TYPE TABLE OF type_mara,
      gt_itab TYPE TABLE OF type_mara,
      lr_matnr TYPE RANGE OF mara-matnr,
      l_matnr LIKE LINE OF lr_matnr.

REFRESH: lt_itab, gt_itab.

SELECT matnr mtart matkl
  INTO TABLE lt_itab
  FROM mara
  WHERE matnr IN s_matnr.

SORT lt_itab BY matnr.

LOOP AT s_matnr WHERE sign EQ 'I'. " for each inclusive criteria
  REFRESH lr_matnr.
  APPEND s_matnr TO lr_matnr.
  LOOP AT lt_itab INTO wa_itab
    WHERE matnr IN lr_matnr.
    DELETE lt_itab. " only once
    APPEND wa_itab TO gt_itab.
  ENDLOOP.
ENDLOOP.
APPEND LINES OF lt_itab TO gt_itab. " if no inclusive criteria&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Raymond&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Jul 2009 08:01:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sort-itab-by-select-options/m-p/5944258#M1335120</guid>
      <dc:creator>RaymondGiuseppi</dc:creator>
      <dc:date>2009-07-30T08:01:08Z</dc:date>
    </item>
    <item>
      <title>Re: sort itab by select-options</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sort-itab-by-select-options/m-p/5944259#M1335121</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;Maybe what you can do is... get the values entered in the select-options, then put it inside an internal table with a counter.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;E.G.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select-option:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2001&lt;/P&gt;&lt;P&gt;2009&lt;/P&gt;&lt;P&gt;2005&lt;/P&gt;&lt;P&gt;2006&lt;/P&gt;&lt;P&gt;2002&lt;/P&gt;&lt;P&gt;2003&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Put it inside an internal table with a counter....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1     2001&lt;/P&gt;&lt;P&gt;2     2009&lt;/P&gt;&lt;P&gt;3     2005&lt;/P&gt;&lt;P&gt;4     2006&lt;/P&gt;&lt;P&gt;5     2002&lt;/P&gt;&lt;P&gt;6     2003&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then sort it by that counter.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just a suggestion.&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;Benedict.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Jul 2009 08:14:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sort-itab-by-select-options/m-p/5944259#M1335121</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-07-30T08:14:59Z</dc:date>
    </item>
    <item>
      <title>Re: sort itab by select-options</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sort-itab-by-select-options/m-p/5944260#M1335122</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Raymond,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;that's what i'm looking for, very simple and good solution.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks for your help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards, Dieter&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Jul 2009 08:25:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sort-itab-by-select-options/m-p/5944260#M1335122</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-07-30T08:25:18Z</dc:date>
    </item>
  </channel>
</rss>

