<?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 internal table in Subroutine in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/sort-internal-table-in-subroutine/m-p/2935778#M691852</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Feng,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use table type in subroutine.&lt;/P&gt;&lt;P&gt;Refer this code :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TYPES: BEGIN OF TYP_SAKNR,&lt;/P&gt;&lt;P&gt;SAKNR LIKE ZTEFI0710-SAKNR, &lt;/P&gt;&lt;P&gt;END OF TYP_SAKNR.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;TYPES  :  ttyp_saknr type standard table of TYP_SAKNR.&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data : TAB_SAKNR  type ttyp_saknr .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FORM GET_SAKNR USING TAB_SAKNR TYPE &amp;lt;b&amp;gt;ttyp_saknr&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;SELECT SAKNR&lt;/P&gt;&lt;P&gt;FROM ZTEFI0710&lt;/P&gt;&lt;P&gt;INTO TABLE TAB_SAKNR&lt;/P&gt;&lt;P&gt;WHERE ZZEURENKETU = '2'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SORT TAB_SAKNR BY SAKNR.&lt;/P&gt;&lt;P&gt;ENDFORM.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now it would work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Hemant&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 23 Oct 2007 07:09:48 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-10-23T07:09:48Z</dc:date>
    <item>
      <title>Sort internal table in Subroutine</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sort-internal-table-in-subroutine/m-p/2935774#M691848</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,everyone.&lt;/P&gt;&lt;P&gt;I want to sort internal table in subroutine , but there is an error.My code is below.&lt;/P&gt;&lt;P&gt;TYPES: BEGIN OF TYP_SAKNR,&lt;/P&gt;&lt;P&gt;          SAKNR LIKE ZTEFI0710-SAKNR, &lt;/P&gt;&lt;P&gt;       END   OF TYP_SAKNR.&lt;/P&gt;&lt;P&gt;DATA:  TAB_SAKNR TYPE STANDARD TABLE OF TYP_SAKNR,&lt;/P&gt;&lt;P&gt;       WA_SAKNR  TYPE TYP_SAKNR.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;START-OF-SELECTION.&lt;/P&gt;&lt;P&gt;  PERFORM GET_SAKNR USING TAB_SAKNR.&lt;/P&gt;&lt;P&gt;  LOOP AT TAB_SAKNR INTO WA_SAKNR.&lt;/P&gt;&lt;P&gt;    WRITE: / WA_SAKNR-SAKNR.&lt;/P&gt;&lt;P&gt;  ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FORM GET_SAKNR USING TAB_SAKNR TYPE STANDARD TABLE.&lt;/P&gt;&lt;P&gt;  SELECT SAKNR&lt;/P&gt;&lt;P&gt;  FROM   ZTEFI0710&lt;/P&gt;&lt;P&gt;  INTO   TABLE TAB_SAKNR&lt;/P&gt;&lt;P&gt;  WHERE  ZZEURENKETU = '2'.&lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt; SORT TAB_SAKNR BY SAKNR.&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;ENDFORM.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I just write SORT TAB_SAKNR, it's ok.&lt;/P&gt;&lt;P&gt;Can you tell me why?And how to solve this problem?&lt;/P&gt;&lt;P&gt;This is an example,if in the internal table there are many fields,and I want to sort this internal table by a few fields in subroutine,what should I do?&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;feng.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Oct 2007 06:59:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sort-internal-table-in-subroutine/m-p/2935774#M691848</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-23T06:59:54Z</dc:date>
    </item>
    <item>
      <title>Re: Sort internal table in Subroutine</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sort-internal-table-in-subroutine/m-p/2935775#M691849</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;
TYPES: BEGIN OF TYP_SAKNR,
SAKNR LIKE ZTEFI0710-SAKNR, 
END OF TYP_SAKNR.
DATA: TAB_SAKNR TYPE STANDARD TABLE OF TYP_SAKNR,
WA_SAKNR TYPE TYP_SAKNR.

START-OF-SELECTION.
PERFORM GET_SAKNR USING TAB_SAKNR.
LOOP AT TAB_SAKNR INTO WA_SAKNR.
WRITE: / WA_SAKNR-SAKNR.
ENDLOOP.

FORM GET_SAKNR USING TAB_SAKNR TYPE STANDARD TABLE OF TYP_SAKNR. " Specify the type of Standard table as TYP_SAKNR
SELECT SAKNR
FROM ZTEFI0710
INTO TABLE TAB_SAKNR
WHERE ZZEURENKETU = '2'.

SORT TAB_SAKNR BY SAKNR.
ENDFORM.


&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Oct 2007 07:05:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sort-internal-table-in-subroutine/m-p/2935775#M691849</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-23T07:05:49Z</dc:date>
    </item>
    <item>
      <title>Re: Sort internal table in Subroutine</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sort-internal-table-in-subroutine/m-p/2935776#M691850</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You need to pass the table using "Tales" key word. something like&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: wa_saknr type typ_saknr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PERFORM GET_SAKNR tables TAB_SAKNR.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FORM GET_SAKNR tables TAB_SAKNR structure wa_saknr.&lt;/P&gt;&lt;P&gt;endform.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reward if useful.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Oct 2007 07:06:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sort-internal-table-in-subroutine/m-p/2935776#M691850</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-23T07:06:27Z</dc:date>
    </item>
    <item>
      <title>Re: Sort internal table in Subroutine</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sort-internal-table-in-subroutine/m-p/2935777#M691851</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Table category of an internal table that is managed using a table index and is &amp;lt;b&amp;gt;always sorted according to its table key&amp;lt;/b&amp;gt;. The corresponding generic data type is sorted table. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;I want to sort this internal table by a few fields in subroutine,what should I do?&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It is not possible to sort the table with any other sort criteria except table key. Otherwise it will give a error. What you can do, inside the subroutine define a standard internal table with same structure and copy the sorted table to that standard table and use it. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IT_sorted_table[] = IT_standard_table[].&lt;/P&gt;&lt;P&gt;and use  IT_standard_table[] instead of IT_sorted_table[].&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Oct 2007 07:09:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sort-internal-table-in-subroutine/m-p/2935777#M691851</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-23T07:09:17Z</dc:date>
    </item>
    <item>
      <title>Re: Sort internal table in Subroutine</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sort-internal-table-in-subroutine/m-p/2935778#M691852</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Feng,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use table type in subroutine.&lt;/P&gt;&lt;P&gt;Refer this code :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TYPES: BEGIN OF TYP_SAKNR,&lt;/P&gt;&lt;P&gt;SAKNR LIKE ZTEFI0710-SAKNR, &lt;/P&gt;&lt;P&gt;END OF TYP_SAKNR.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;TYPES  :  ttyp_saknr type standard table of TYP_SAKNR.&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data : TAB_SAKNR  type ttyp_saknr .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FORM GET_SAKNR USING TAB_SAKNR TYPE &amp;lt;b&amp;gt;ttyp_saknr&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;SELECT SAKNR&lt;/P&gt;&lt;P&gt;FROM ZTEFI0710&lt;/P&gt;&lt;P&gt;INTO TABLE TAB_SAKNR&lt;/P&gt;&lt;P&gt;WHERE ZZEURENKETU = '2'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SORT TAB_SAKNR BY SAKNR.&lt;/P&gt;&lt;P&gt;ENDFORM.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now it would work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Hemant&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Oct 2007 07:09:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sort-internal-table-in-subroutine/m-p/2935778#M691852</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-23T07:09:48Z</dc:date>
    </item>
    <item>
      <title>Re: Sort internal table in Subroutine</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sort-internal-table-in-subroutine/m-p/2935779#M691853</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;If u want to sort the internal table by few fields just give&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sort it_matnr by f1 f2 ... fn&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;where f1 , f2 ... fn are the fields on which u want to sort the internal table.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Oct 2007 07:10:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sort-internal-table-in-subroutine/m-p/2935779#M691853</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-23T07:10:03Z</dc:date>
    </item>
    <item>
      <title>Re: Sort internal table in Subroutine</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sort-internal-table-in-subroutine/m-p/2935780#M691854</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks,Prashant Patil .&lt;/P&gt;&lt;P&gt;I tried,but it didn't work.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;feng.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Oct 2007 07:18:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sort-internal-table-in-subroutine/m-p/2935780#M691854</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-23T07:18:00Z</dc:date>
    </item>
  </channel>
</rss>

