<?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/8446717#M1649135</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi fried,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try the code below it works fine.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TYPES : BEGIN OF ty_text,&lt;/P&gt;&lt;P&gt;        text1 type char11,&lt;/P&gt;&lt;P&gt;        text2 TYPE char11,&lt;/P&gt;&lt;P&gt;        count TYPE i,&lt;/P&gt;&lt;P&gt;        END OF ty_text.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data : t_text TYPE TABLE OF ty_text,&lt;/P&gt;&lt;P&gt;       x_text TYPE ty_text.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA : v_count TYPE i.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;x_text-text1 = 'rent'.&lt;/P&gt;&lt;P&gt;x_text-text2 = 'xyz'.&lt;/P&gt;&lt;P&gt;append x_text to t_text.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;x_text-text1 = 'media'.&lt;/P&gt;&lt;P&gt;x_text-text2 = 'media'.&lt;/P&gt;&lt;P&gt;append x_text to t_text.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;x_text-text1 = 'rent'.&lt;/P&gt;&lt;P&gt;x_text-text2 = 'media media'.&lt;/P&gt;&lt;P&gt;append x_text to t_text.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at t_text INTO x_text.&lt;/P&gt;&lt;P&gt;if x_text-text1 eq 'media' or x_text-text1 eq 'rent'.&lt;/P&gt;&lt;P&gt;  v_count = v_count + 1.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;if x_text-text2 eq 'media' or x_text-text2 eq 'rent'.&lt;/P&gt;&lt;P&gt;  v_count = v_count + 1.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;x_text-count = v_count.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MODIFY t_text INDEX sy-tabix FROM x_text.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;clear v_count.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SORT t_text DESCENDING by count.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you face any issues please revert back to me i will help you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Sri Hari&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 05 Jan 2012 05:09:04 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2012-01-05T05:09:04Z</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/8446716#M1649134</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;As per my requirement i need to search for words in internal table and arrange internal table based on ranking i.e record which has maximum no. of hits should come first.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example: search for a string 'media rent'.&lt;/P&gt;&lt;P&gt;Incoming internal table records.&lt;/P&gt;&lt;P&gt;row1------&amp;gt;   col1: rent                    col::xyz  &lt;/P&gt;&lt;P&gt;row2 -&lt;/P&gt;&lt;HR originaltext="----" /&gt;&lt;P&gt;&amp;gt;   col1:media rent          col2:media&lt;/P&gt;&lt;P&gt;row3 -&lt;/P&gt;&lt;HR originaltext="----" /&gt;&lt;P&gt;&amp;gt;  col1: rent                     col2:media  media &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need to compare each word in col1 and col2 and arrange the rows based on ranking like this:&lt;/P&gt;&lt;P&gt;final internal table&lt;/P&gt;&lt;P&gt;row2 because it has maximum no. of search term&lt;/P&gt;&lt;P&gt;row3 &lt;/P&gt;&lt;P&gt;row1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I found out 2 ways to do the above but facing some issues and need your suggestions:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Solution 1:&lt;/P&gt;&lt;P&gt;By using regualr expression i am searching as OR expression on itab.&lt;/P&gt;&lt;P&gt;and using FIND ALL OCCURRENCES OF REGEX command on each column of internal table &lt;/P&gt;&lt;P&gt;Issue: when row3 is scanned for 'media rent' it will give 3 counts i which will lead to move row3  on top in final table due to maximum no of counts.&lt;/P&gt;&lt;P&gt;Is there a way to neglect 2nd occurence in the word ? I cn't use find first occurence here.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Solution 2:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Split search sting 'media rent' into internal table&lt;/P&gt;&lt;P&gt;itab1 &lt;/P&gt;&lt;P&gt;media &lt;/P&gt;&lt;P&gt;rent&lt;/P&gt;&lt;P&gt;and search for each word in each row of internal table and make use of counter something like this.i am unable to proceed further here&lt;/P&gt;&lt;P&gt;I am stucked with what kind of logic should be here ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Looking for your suggestions here.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Jan 2012 04:47:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/search-in-internal-table-utility-need-pointers/m-p/8446716#M1649134</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2012-01-05T04:47:45Z</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/8446717#M1649135</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi fried,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try the code below it works fine.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TYPES : BEGIN OF ty_text,&lt;/P&gt;&lt;P&gt;        text1 type char11,&lt;/P&gt;&lt;P&gt;        text2 TYPE char11,&lt;/P&gt;&lt;P&gt;        count TYPE i,&lt;/P&gt;&lt;P&gt;        END OF ty_text.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data : t_text TYPE TABLE OF ty_text,&lt;/P&gt;&lt;P&gt;       x_text TYPE ty_text.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA : v_count TYPE i.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;x_text-text1 = 'rent'.&lt;/P&gt;&lt;P&gt;x_text-text2 = 'xyz'.&lt;/P&gt;&lt;P&gt;append x_text to t_text.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;x_text-text1 = 'media'.&lt;/P&gt;&lt;P&gt;x_text-text2 = 'media'.&lt;/P&gt;&lt;P&gt;append x_text to t_text.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;x_text-text1 = 'rent'.&lt;/P&gt;&lt;P&gt;x_text-text2 = 'media media'.&lt;/P&gt;&lt;P&gt;append x_text to t_text.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at t_text INTO x_text.&lt;/P&gt;&lt;P&gt;if x_text-text1 eq 'media' or x_text-text1 eq 'rent'.&lt;/P&gt;&lt;P&gt;  v_count = v_count + 1.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;if x_text-text2 eq 'media' or x_text-text2 eq 'rent'.&lt;/P&gt;&lt;P&gt;  v_count = v_count + 1.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;x_text-count = v_count.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MODIFY t_text INDEX sy-tabix FROM x_text.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;clear v_count.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SORT t_text DESCENDING by count.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you face any issues please revert back to me i will help you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Sri Hari&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Jan 2012 05:09:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/search-in-internal-table-utility-need-pointers/m-p/8446717#M1649135</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2012-01-05T05:09:04Z</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/8446718#M1649136</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Closing the thread. Solved by myself.&lt;/P&gt;&lt;P&gt;Thanks sri for your inputs.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Jan 2012 05:59:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/search-in-internal-table-utility-need-pointers/m-p/8446718#M1649136</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2012-01-05T05:59:46Z</dc:date>
    </item>
  </channel>
</rss>

