<?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 table by field position? in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/sort-table-by-field-position/m-p/2201554#M470443</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I thought of that solution, but I was trying for something that doesn't require a 'work table' or translating based on a rule.  It may not be possible.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 25 Apr 2007 19:28:46 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-04-25T19:28:46Z</dc:date>
    <item>
      <title>Sort table by field position?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sort-table-by-field-position/m-p/2201552#M470441</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is it possible to sort a table by field position?  For example, I have table ITAB with a 4 character field F1.  I want to sort the table first by the 3rd position ( itab-f1&lt;EM&gt;2(1) ) ascending then the 4th position ( itab-f1&lt;/EM&gt;3(1) ) descending.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: begin of itab occurs 0,&lt;/P&gt;&lt;P&gt;          f1(4),&lt;/P&gt;&lt;P&gt;        end of itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;itab-f1 = '01AC'.&lt;/P&gt;&lt;P&gt;append itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;itab-f1 = '02AB'.&lt;/P&gt;&lt;P&gt;append itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;itab-f1 = '01CD'.&lt;/P&gt;&lt;P&gt;append itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;itab-f1 = '02CA'.&lt;/P&gt;&lt;P&gt;append itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sort itab...  &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I thought about using TRANSLATE with a rule and converting each position to a numeric value (then transfer the value to a new 'sort' field), but I wasn't sure if there was an easier way.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The sorted table should read:  '01AC' ; '02AB' ; '01CD' ; '02CA'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help is appreciated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Apr 2007 17:11:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sort-table-by-field-position/m-p/2201552#M470441</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-04-25T17:11:35Z</dc:date>
    </item>
    <item>
      <title>Re: Sort table by field position?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sort-table-by-field-position/m-p/2201553#M470442</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;Please try this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
DATA: BEGIN OF ITAB OCCURS 0,
        F1(4),
      END OF ITAB.
                                                                        
DATA: BEGIN OF ITAB2 OCCURS 0,
        F1(1),
        F2(1),
        F3(4),
      END OF ITAB2.
                                                                        
ITAB-F1 = '01AC'.
APPEND ITAB.
                                                                        
ITAB-F1 = '02AB'.
APPEND ITAB.
                                                                        
ITAB-F1 = '01CD'.
APPEND ITAB.
                                                                        
ITAB-F1 = '02CA'.
APPEND ITAB.

LOOP AT ITAB.
  ITAB2-F1 = ITAB-F1+2(1).
  ITAB2-F2 = ITAB-F1+3(1).
  ITAB2-F3 = ITAB-F1.
  APPEND ITAB2.
ENDLOOP.
                                                                        
SORT ITAB2 BY F1 ASCENDING
              F2 DESCENDING.
                                                                        
LOOP AT ITAB2.
  WRITE: / ITAB2-F3.
ENDLOOP.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Ferry Lianto&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Apr 2007 17:28:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sort-table-by-field-position/m-p/2201553#M470442</guid>
      <dc:creator>ferry_lianto</dc:creator>
      <dc:date>2007-04-25T17:28:32Z</dc:date>
    </item>
    <item>
      <title>Re: Sort table by field position?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sort-table-by-field-position/m-p/2201554#M470443</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I thought of that solution, but I was trying for something that doesn't require a 'work table' or translating based on a rule.  It may not be possible.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Apr 2007 19:28:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sort-table-by-field-position/m-p/2201554#M470443</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-04-25T19:28:46Z</dc:date>
    </item>
    <item>
      <title>Re: Sort table by field position?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sort-table-by-field-position/m-p/2201555#M470444</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Cal,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't think possible without creating another internal table.&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;Ferry Lianto&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Apr 2007 19:31:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sort-table-by-field-position/m-p/2201555#M470444</guid>
      <dc:creator>ferry_lianto</dc:creator>
      <dc:date>2007-04-25T19:31:16Z</dc:date>
    </item>
    <item>
      <title>Re: Sort table by field position?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sort-table-by-field-position/m-p/2201556#M470445</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;You cannot sort using some characters of the field. You will need internal table to sort it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Apr 2007 20:41:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sort-table-by-field-position/m-p/2201556#M470445</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-04-25T20:41:08Z</dc:date>
    </item>
  </channel>
</rss>

