<?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: Search in Internal Table Utility -- Need Pointers in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/search-in-internal-table-utility-need-pointers/m-p/8448358#M1649281</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;bhanu,&lt;/P&gt;&lt;P&gt;2 possible solutions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. store the LV_F1 as a column in the IT_JOB_OUT, so that once you come out of the second loop you can just sort the table IT_JOB_OUT descending by that LV_F1 field and bingo.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. store the lv_f1 value in another variable to hold the value from previous loop. &lt;/P&gt;&lt;P&gt;and do a if statement like if lv_f1 &amp;gt; lv_old then insert at a higer index, else append.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;but i think the first option is way easier that the second&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 21 Dec 2011 05:44:13 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2011-12-21T05:44:13Z</dc:date>
    <item>
      <title>Search in Internal Table Utility -- Need Pointers</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/search-in-internal-table-utility-need-pointers/m-p/8448356#M1649279</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Experts,&lt;/P&gt;&lt;P&gt;I am working on a static class which will be used in many programs to search for a phrase in internal table.&lt;/P&gt;&lt;P&gt;INPUT PARAMETERS  of my class :&lt;/P&gt;&lt;P&gt;1.SEARCH_STRING type string:   This parameter is used to pass search string to search in ITAB&lt;/P&gt;&lt;P&gt;2.FIELD_NAMES     type table of string: This parameter will be passed with field names .(this parameter tells in which fields of ITAB the search string needs to be searched.&lt;/P&gt;&lt;P&gt;3. ITAB                    type   table. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;OUTPUT Parameter:&lt;/P&gt;&lt;P&gt;IT_JOB_OUT  type table&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Below is my code:&lt;/P&gt;&lt;P&gt;LOOP AT ITAB  ASSIGNING &amp;lt;FS_JOB_LIST&amp;gt;.&lt;/P&gt;&lt;P&gt;    LV_INDEX = SY-TABIX.&lt;/P&gt;&lt;P&gt;    CLEAR:LV_F1,LV_F2,LV_F3,LV_F4,LV_F5,LV_F6,LV_F7,LV_F8,LV_TOTAL.&lt;/P&gt;&lt;P&gt;    LOOP AT FIELD_NAMES ASSIGNING  &amp;lt;FIELD_NAME&amp;gt;.&lt;/P&gt;&lt;P&gt;      ASSIGN COMPONENT &amp;lt;FIELD_NAME&amp;gt; OF STRUCTURE &amp;lt;FS_JOB_LIST&amp;gt; TO &amp;lt;FIELD&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      FIND ALL OCCURRENCES OF  SEARCH_STRING&lt;/P&gt;&lt;P&gt;      IN                       &amp;lt;FIELD&amp;gt; IN CHARACTER MODE&lt;/P&gt;&lt;P&gt;                               MATCH COUNT MCOUN.&lt;/P&gt;&lt;P&gt;      IF SY-SUBRC = 0.&lt;/P&gt;&lt;P&gt;        LV_F1       = LV_F1 + 1.&lt;/P&gt;&lt;P&gt;      ENDIF.&lt;/P&gt;&lt;P&gt;    ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;   if   LV_F1 &amp;gt; 0.&lt;/P&gt;&lt;P&gt;   APPEND &amp;lt;FS_JOB_LIST&amp;gt; TO IT_JOB_OUT.&lt;/P&gt;&lt;P&gt;   endif.&lt;/P&gt;&lt;P&gt;  endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Scenario:&lt;/P&gt;&lt;P&gt;I want to arrange the internal table IT_JOB_OUT   based on ranking of search term.&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P&gt;SEARCH_STRING  = 'TEST RANK'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ITAB DATA &lt;/P&gt;&lt;P&gt;ROW 1 FIELD1 VALUE "ABC"             FIELD2 VALUE "TEST RANK".&lt;/P&gt;&lt;P&gt;ROW 2 FIELD1 VALUE "TEST RANK"    FIELD2 VALUE "TEST RANK".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The above code will give sy-subrc = 0 after find statement for both rows and  result as &lt;/P&gt;&lt;P&gt;IT_JOB_OUT&lt;/P&gt;&lt;P&gt;ROW 1 FIELD1 VALUE "ABC"             FIELD2 VALUE "TEST RANK".&lt;/P&gt;&lt;P&gt;ROW 2 FIELD1 VALUE "TEST RANK"    FIELD2 VALUE "TEST RANK".&lt;/P&gt;&lt;P&gt;I want o/p as &lt;/P&gt;&lt;P&gt;ROW 1 FIELD1 VALUE "TEST RANK"    FIELD2 VALUE "TEST RANK".&lt;/P&gt;&lt;P&gt;ROW 2 FIELD1 VALUE "ABC"             FIELD2 VALUE "TEST RANK".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;my problem is:&lt;/P&gt;&lt;P&gt; I want to arrange my output table such that maximum hits row should come first in above example my final table&lt;/P&gt;&lt;P&gt;should be ROW2 then ROW1. How can i achieve this ? Please note IT_JOB_OUT is of type table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please need your  suggestions on this.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Bhanu&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Dec 2011 04:14:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/search-in-internal-table-utility-need-pointers/m-p/8448356#M1649279</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-12-21T04:14:20Z</dc:date>
    </item>
    <item>
      <title>Re: Search in Internal Table Utility -- Need Pointers</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/search-in-internal-table-utility-need-pointers/m-p/8448357#M1649280</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;Why cant you use the SEARCH functionality provided by SAP to identify if there is a pattern available in the internal table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SEARCH itab FOR pattern [IN {BYTE|CHARACTER} MODE] &lt;/P&gt;&lt;P&gt;       [STARTING AT idx1] [ENDING AT idx2] &lt;/P&gt;&lt;P&gt;       [ABBREVIATED] &lt;/P&gt;&lt;P&gt;       [AND MARK]. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The result of which populates the SY-TABIX with the row of the table and SY-FDPOS with the offset.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks and Regards,&lt;/P&gt;&lt;P&gt;Sriranjani Chimakurthy.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Dec 2011 05:32:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/search-in-internal-table-utility-need-pointers/m-p/8448357#M1649280</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-12-21T05:32:22Z</dc:date>
    </item>
    <item>
      <title>Re: Search in Internal Table Utility -- Need Pointers</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/search-in-internal-table-utility-need-pointers/m-p/8448358#M1649281</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;bhanu,&lt;/P&gt;&lt;P&gt;2 possible solutions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. store the LV_F1 as a column in the IT_JOB_OUT, so that once you come out of the second loop you can just sort the table IT_JOB_OUT descending by that LV_F1 field and bingo.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. store the lv_f1 value in another variable to hold the value from previous loop. &lt;/P&gt;&lt;P&gt;and do a if statement like if lv_f1 &amp;gt; lv_old then insert at a higer index, else append.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;but i think the first option is way easier that the second&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Dec 2011 05:44:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/search-in-internal-table-utility-need-pointers/m-p/8448358#M1649281</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-12-21T05:44:13Z</dc:date>
    </item>
    <item>
      <title>Re: Search in Internal Table Utility -- Need Pointers</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/search-in-internal-table-utility-need-pointers/m-p/8448359#M1649282</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Sriranjani Chimakurthy &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Search wont work here&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. SEARCH itab FOR pattern  as you said will only work for itab which has all Char  fields which is not the case.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2.itab FOR pattern  will search for pattern not the phrase.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Dec 2011 05:46:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/search-in-internal-table-utility-need-pointers/m-p/8448359#M1649282</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-12-21T05:46:47Z</dc:date>
    </item>
    <item>
      <title>Re: Search in Internal Table Utility -- Need Pointers</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/search-in-internal-table-utility-need-pointers/m-p/8448360#M1649283</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Soumyaprakash,&lt;/P&gt;&lt;P&gt;This is what i exactly thought but how  can i add a column to IT_JOB_OUT which is of type table?&lt;/P&gt;&lt;P&gt;I am using generic types as my class will be used in many programs so the only way was to keep the internal table&lt;/P&gt;&lt;P&gt;generic.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But how can i add a column to my ITAB ??&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please suggest &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Bhanu&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Dec 2011 05:50:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/search-in-internal-table-utility-need-pointers/m-p/8448360#M1649283</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-12-21T05:50:17Z</dc:date>
    </item>
    <item>
      <title>Re: Search in Internal Table Utility -- Need Pointers</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/search-in-internal-table-utility-need-pointers/m-p/8448361#M1649284</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;define/Create a intermediate table with this column. pass it there, sort it there. then pass the required data to your final table. wont that do?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Dec 2011 06:08:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/search-in-internal-table-utility-need-pointers/m-p/8448361#M1649284</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-12-21T06:08:07Z</dc:date>
    </item>
    <item>
      <title>Re: Search in Internal Table Utility -- Need Pointers</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/search-in-internal-table-utility-need-pointers/m-p/8448362#M1649285</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the reply Soumyaprakash,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i was trying to create a internal table but what should be the type of my internal table???&lt;/P&gt;&lt;P&gt;The way you described it should work fine but what should be the structure of my ITAB?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT IT_JOB_LIST_IN  ASSIGNING &amp;lt;FS_JOB_LIST&amp;gt;.&lt;/P&gt;&lt;P&gt;    LV_INDEX = SY-TABIX.&lt;/P&gt;&lt;P&gt;    CLEAR:LV_F1,LV_F2,LV_F3,LV_F4,LV_F5,LV_F6,LV_F7,LV_F8,LV_TOTAL.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    LOOP AT IT_FIELD_NAME ASSIGNING  &amp;lt;FIELD_NAME&amp;gt;.&lt;/P&gt;&lt;P&gt;      ASSIGN COMPONENT &amp;lt;FIELD_NAME&amp;gt; OF STRUCTURE &amp;lt;FS_JOB_LIST&amp;gt; TO &amp;lt;FIELD&amp;gt;.&lt;/P&gt;&lt;P&gt;      FIND ALL OCCURRENCES OF  I_SEARCH_STRING&lt;/P&gt;&lt;P&gt;      IN                       &amp;lt;FIELD&amp;gt; IN CHARACTER MODE&lt;/P&gt;&lt;P&gt;                               MATCH COUNT MCOUN.&lt;/P&gt;&lt;P&gt;      IF SY-SUBRC = 0.&lt;/P&gt;&lt;P&gt;        LV_F1       = LV_F1 + 1.&lt;/P&gt;&lt;P&gt;      ENDIF.&lt;/P&gt;&lt;P&gt;    ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    IF LV_F1 &amp;gt; 0.&lt;/P&gt;&lt;P&gt;       move &amp;lt;FS_JOB_LIST&amp;gt;  to WA.&lt;/P&gt;&lt;P&gt;       wa-count = LV_F1.&lt;/P&gt;&lt;P&gt;      APPEND WA  TO ITAB. &lt;/P&gt;&lt;P&gt;      DELETE  IT_JOB_LIST_IN INDEX LV_INDEX.&lt;/P&gt;&lt;P&gt;    ENDIF.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Dec 2011 06:26:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/search-in-internal-table-utility-need-pointers/m-p/8448362#M1649285</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-12-21T06:26:27Z</dc:date>
    </item>
    <item>
      <title>Re: Search in Internal Table Utility -- Need Pointers</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/search-in-internal-table-utility-need-pointers/m-p/8448363#M1649286</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Bhanu,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is what i exactly thought but how can i add a column to IT_JOB_OUT which is of type table?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use RTTS class to build up your table structure dynamically and add the field you need... &lt;/P&gt;&lt;P&gt;I guess CL_ABAP_STRUCTDESCR should be enough for this... Once your structure is built, use a CREATE DATA statement to create the object and dereference it to a field symbol to be able to insert the record to your table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kr,&lt;/P&gt;&lt;P&gt;Manu.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Dec 2011 11:27:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/search-in-internal-table-utility-need-pointers/m-p/8448363#M1649286</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-12-21T11:27:37Z</dc:date>
    </item>
    <item>
      <title>Re: Search in Internal Table Utility -- Need Pointers</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/search-in-internal-table-utility-need-pointers/m-p/8448364#M1649287</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;[useless]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Manu D'Haeyer on Dec 21, 2011 5:03 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Dec 2011 11:50:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/search-in-internal-table-utility-need-pointers/m-p/8448364#M1649287</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-12-21T11:50:44Z</dc:date>
    </item>
  </channel>
</rss>

