<?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 internal table based on field value in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-internal-table-based-on-field-value/m-p/2336652#M514547</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think what you need to do is after you have printed your table then sort it by bschl and simply read the value you are looking for, and lastly print the record.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SORT gt_bseg BY bschl.
READ TABLE gt_bseg INTO lc_bseg WITH KEY bschl = '15'.
IF SY-SUBRC &amp;lt;&amp;gt; 0.
READ TABLE gt_bseg INTO lc_bseg WITH KEY bschl = '06'.
ENDIF.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 05 Jun 2007 09:38:51 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-06-05T09:38:51Z</dc:date>
    <item>
      <title>sorting internal table based on field value</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-internal-table-based-on-field-value/m-p/2336651#M514546</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 wanna sort the internal table gt_bseg based on the posting key value. &lt;/P&gt;&lt;P&gt;that is if the posting key (bseg-bschl) is equal to 06 or 15, the particular record should become the last record of gt_bseg.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;as i want to print this record after printing the total internal table so i want to make the record havong posting key as 06 or 15 as last record of itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;please help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Jun 2007 09:29:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-internal-table-based-on-field-value/m-p/2336651#M514546</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-06-05T09:29:42Z</dc:date>
    </item>
    <item>
      <title>Re: sorting internal table based on field value</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-internal-table-based-on-field-value/m-p/2336652#M514547</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think what you need to do is after you have printed your table then sort it by bschl and simply read the value you are looking for, and lastly print the record.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SORT gt_bseg BY bschl.
READ TABLE gt_bseg INTO lc_bseg WITH KEY bschl = '15'.
IF SY-SUBRC &amp;lt;&amp;gt; 0.
READ TABLE gt_bseg INTO lc_bseg WITH KEY bschl = '06'.
ENDIF.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Jun 2007 09:38:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-internal-table-based-on-field-value/m-p/2336652#M514547</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-06-05T09:38:51Z</dc:date>
    </item>
    <item>
      <title>Re: sorting internal table based on field value</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-internal-table-based-on-field-value/m-p/2336653#M514548</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;What you can do is to create a dummy field in your internal table&lt;/P&gt;&lt;P&gt;whenever bseg-bschl = 06 or 15 set the value of that field to something (eg: 1)&lt;/P&gt;&lt;P&gt;then sort the internal table by that dummy field&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Jun 2007 09:40:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-internal-table-based-on-field-value/m-p/2336653#M514548</guid>
      <dc:creator>former_member189059</dc:creator>
      <dc:date>2007-06-05T09:40:18Z</dc:date>
    </item>
    <item>
      <title>Re: sorting internal table based on field value</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-internal-table-based-on-field-value/m-p/2336654#M514549</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi&lt;/P&gt;&lt;P&gt;good&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;go through this and use accordinlgy&lt;/P&gt;&lt;P&gt;You can sort a standard or hashed table in a program. To sort a table by its key, use the statement&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SORT &amp;lt;itab&amp;gt; [ASCENDING|DESCENDING] [AS TEXT] [STABLE].&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The statement sorts the internal table &amp;lt;itab&amp;gt; in ascending order by its key. The statement always applies to the table itself, not to the header line. The sort order depends on the sequence of the standard key fields in the internal table. The default key is made up of the non-numeric fields of the table line in the order in which they occur. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can specify the direction of the sort using the additions ASCENDING and DESCENDING. The default is ascending.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The larger the sort key, the more time the system needs to sort the table. If the sort key contains an internal table, the sorting process may be slowed down considerably.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You cannot sort a sorted table using the SORT statement. The system always maintains these tables automatically by their sort order. If an internal table is statically recognizable as a sorted table, the SORT statement causes a syntax error. If the table is a generic sorted table, the SORT statement causes a runtime error if the sort key is not the same as an extract of the beginning of the table key, you sort in descending order, or use the AS TEXT addition. In other words, the SORT statement is only allowed for generic internal tables, if it does not violate the internal sort order. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://help.sap.com/saphelp_sm32/helpdata/en/fc/eb3800358411d1829f0000e829fbfe/content.htm" target="test_blank"&gt;http://help.sap.com/saphelp_sm32/helpdata/en/fc/eb3800358411d1829f0000e829fbfe/content.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;P&gt;mrutyun^&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Jun 2007 10:00:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-internal-table-based-on-field-value/m-p/2336654#M514549</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-06-05T10:00:49Z</dc:date>
    </item>
    <item>
      <title>Re: sorting internal table based on field value</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-internal-table-based-on-field-value/m-p/2336655#M514550</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;Create one more internal table of similar structure.&lt;/P&gt;&lt;P&gt;say it is itab1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at itab into wa where bschl &amp;lt;&amp;gt; '06' and bschl &amp;lt;&amp;gt; '15.&lt;/P&gt;&lt;P&gt;append wa to itab1.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;loop at itab into wa where bschl = '06' .&lt;/P&gt;&lt;P&gt;append wa to itab1.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;loop at itab into wa where bschl = '15.&lt;/P&gt;&lt;P&gt;append wa to itab1.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now itab1 will records in the sorted order according to the requirement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kindly reward points by clicking the star on the left of reply,if it helps.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Jun 2007 10:07:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sorting-internal-table-based-on-field-value/m-p/2336655#M514550</guid>
      <dc:creator>jayanthi_jayaraman</dc:creator>
      <dc:date>2007-06-05T10:07:26Z</dc:date>
    </item>
  </channel>
</rss>

