<?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: internal table operations in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-operations/m-p/1574402#M259354</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Praveen,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since it is Loop inside Loop. There is no point in having :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Loop T1.&lt;/P&gt;&lt;P&gt;Read T2 with key F1 = T1-f1.&lt;/P&gt;&lt;P&gt;append T2 to T3.&lt;/P&gt;&lt;P&gt;Endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The above logic will add only one(Same )record from T2 to T3 though there could be more than 1 record where T2-F1 = T1-F1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;The current logic which you have written is correct and its the best way to do it.&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;I would suggest not to look out for any other alternative except SORTING.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SORT T1 By F1.&lt;/P&gt;&lt;P&gt;Sort T2 by F2.&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Prashant&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PS : Please reward all helpful answers&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 18 Sep 2006 10:29:03 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2006-09-18T10:29:03Z</dc:date>
    <item>
      <title>internal table operations</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-operations/m-p/1574394#M259346</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;   Please tell me the alternative of using loop that is specified in Bold. some body saying that is an alternative of using some statement without using loop in loop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;* data declaration
DATA: BEGIN OF T1 OCCURS 0,
F1 TYPE I,
END OF T1.

DATA: BEGIN OF T2 OCCURS 0,
F1 TYPE I,
F2(10) TYPE C,
END OF T2.

DATA: T3 LIKE T2 OCCURS 0 WITH HEADER LINE.


* fill internal table T1
T1-F1 =  10.
APPEND T1.

T1-F1 =  20.
APPEND T1.

T1-F1 =  30.
APPEND T1.

T1-F1 =  40.
APPEND T1.

* fill internal table T2
T2-F1 =  10.
T2-F2 = 'AA'.
APPEND T2.

T2-F1 =  10.
T2-F2 = 'AB'.
APPEND T2.

T2-F1 =  10.
T2-F2 = 'AC'.
APPEND T2.

T2-F1 =  20.
T2-F2 = 'BA'.
APPEND T2.

T2-F1 =  20.
T2-F2 = 'BB'.
APPEND T2.

T2-F1 =  30.
T2-F2 = 'CA'.
APPEND T2.

T2-F1 =  30.
T2-F2 = 'CB'.
APPEND T2.

T2-F1 =  30.
T2-F2 = 'CC'.
APPEND T2.

T2-F1 =  40.
T2-F2 = 'DA'.
APPEND T2.

CLEAR: T1, T2.

* fill internal table T1
LOOP AT T1.
&amp;lt;b&amp;gt;  LOOP AT T2 WHERE F1 = T1-F1.
    APPEND T2 TO T3.
  ENDLOOP.&amp;lt;/b&amp;gt;
ENDLOOP.

* display internal table T1
LOOP AT T3.
  WRITE:/ T3-F1, T3-F2.
ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Sep 2006 10:18:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-operations/m-p/1574394#M259346</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-09-18T10:18:22Z</dc:date>
    </item>
    <item>
      <title>Re: internal table operations</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-operations/m-p/1574395#M259347</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can do something like this :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT T1.&lt;/P&gt;&lt;P&gt;read table t2 with key f1 = t1-fi binary search.&lt;/P&gt;&lt;P&gt;if sy-subrc eq 0.&lt;/P&gt;&lt;P&gt;    APPEND T2 TO T3.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt; ENDLOOP.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Sep 2006 10:21:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-operations/m-p/1574395#M259347</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-09-18T10:21:27Z</dc:date>
    </item>
    <item>
      <title>Re: internal table operations</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-operations/m-p/1574396#M259348</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 could use Read table with key instead of loop within loop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rgds,&lt;/P&gt;&lt;P&gt;HR&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Sep 2006 10:21:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-operations/m-p/1574396#M259348</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-09-18T10:21:49Z</dc:date>
    </item>
    <item>
      <title>Re: internal table operations</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-operations/m-p/1574397#M259349</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 can use&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;fill internal table T1&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;LOOP AT T2.&lt;/P&gt;&lt;P&gt;  move-corresponding T2 to T3.&lt;/P&gt;&lt;P&gt;  collect T3.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Write T3 contents. (All records of T2 are collected (&amp;lt;b&amp;gt;summated&amp;lt;/b&amp;gt;) based on the value F2)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Raj&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Sep 2006 10:23:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-operations/m-p/1574397#M259349</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-09-18T10:23:20Z</dc:date>
    </item>
    <item>
      <title>Re: internal table operations</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-operations/m-p/1574398#M259350</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;Since you are populating the value for T1 and T2 manually, why not by populate all the value into one single internal table?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Sep 2006 10:24:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-operations/m-p/1574398#M259350</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-09-18T10:24:47Z</dc:date>
    </item>
    <item>
      <title>Re: internal table operations</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-operations/m-p/1574399#M259351</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;   use below code which is best performance wise &lt;/P&gt;&lt;P&gt;  sort t2 by f1.&lt;/P&gt;&lt;P&gt;data lv_index like sy-tabix.&lt;/P&gt;&lt;P&gt;LOOP AT T1.&lt;/P&gt;&lt;P&gt;  clear lc_index.&lt;/P&gt;&lt;P&gt;   read table t2 with key f1 = t1-f1 binary search.&lt;/P&gt;&lt;P&gt;   if sy-subrc eq 0.&lt;/P&gt;&lt;P&gt;    lv_index = sy-tabix.&lt;/P&gt;&lt;P&gt;  LOOP AT T2 from lv_index.&lt;/P&gt;&lt;P&gt;   if t1-f1 &amp;lt;&amp;gt; t2-f1.&lt;/P&gt;&lt;P&gt;    exit.&lt;/P&gt;&lt;P&gt;   endif. &lt;/P&gt;&lt;P&gt;    APPEND T2 TO T3.&lt;/P&gt;&lt;P&gt;  ENDLOOP.&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;Regards&lt;/P&gt;&lt;P&gt;Amole&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;amole&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Sep 2006 10:26:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-operations/m-p/1574399#M259351</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-09-18T10:26:44Z</dc:date>
    </item>
    <item>
      <title>Re: internal table operations</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-operations/m-p/1574400#M259352</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;   I guess for this case, there is no alternative statements as you have data in two internal tables. But&lt;/P&gt;&lt;P&gt;YES you can minimise during extraction via FOR ALL ENTRIES.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Eg:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;tables: mara.
select-options: s_matnr for mara-matnr.
types: begin of t_mara,
         matnr like mara-matnr,
         mtart like mara-mtart,
       end of t_mara.
types: begin of t_marc,
         matnr like marc-matnr,
         werks like marc-werks,
       end of t_marc.
data: it_mara type standard table of t_mara,
      it_marc type standard table of t_marc.

select matnr mtart into table it_mara
       from mara
       where matnr in s_matnr.

select matnr werks into table it_marc
       from marc
       for all entries in it_mara
       where matnr = it_mara-matnr.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Kind Regards&lt;/P&gt;&lt;P&gt;Eswar&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Sep 2006 10:27:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-operations/m-p/1574400#M259352</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-09-18T10:27:29Z</dc:date>
    </item>
    <item>
      <title>Re: internal table operations</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-operations/m-p/1574401#M259353</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;use READ stmt..&lt;/P&gt;&lt;P&gt;SORT T2.&lt;/P&gt;&lt;P&gt;LOOP AT T1.  &lt;/P&gt;&lt;P&gt;READ TABLE T2 WHERE F1 = T1-F1 BINARY SEARCH.&lt;/P&gt;&lt;P&gt;APPEND T2 TO T3.  &lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;hope this helps,&lt;/P&gt;&lt;P&gt;do reward if it helps,&lt;/P&gt;&lt;P&gt;priya.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Sep 2006 10:28:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-operations/m-p/1574401#M259353</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-09-18T10:28:23Z</dc:date>
    </item>
    <item>
      <title>Re: internal table operations</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-operations/m-p/1574402#M259354</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Praveen,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since it is Loop inside Loop. There is no point in having :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Loop T1.&lt;/P&gt;&lt;P&gt;Read T2 with key F1 = T1-f1.&lt;/P&gt;&lt;P&gt;append T2 to T3.&lt;/P&gt;&lt;P&gt;Endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The above logic will add only one(Same )record from T2 to T3 though there could be more than 1 record where T2-F1 = T1-F1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;The current logic which you have written is correct and its the best way to do it.&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;I would suggest not to look out for any other alternative except SORTING.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SORT T1 By F1.&lt;/P&gt;&lt;P&gt;Sort T2 by F2.&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Prashant&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PS : Please reward all helpful answers&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Sep 2006 10:29:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-operations/m-p/1574402#M259354</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-09-18T10:29:03Z</dc:date>
    </item>
    <item>
      <title>Re: internal table operations</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-operations/m-p/1574403#M259355</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Praveen,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you can do the following with out usign loop in loop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;t3[] = t2[].&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at t3.&lt;/P&gt;&lt;P&gt;  v_index = sy-tabix.&lt;/P&gt;&lt;P&gt;  read table t1 with key f1 = t3-f1.&lt;/P&gt;&lt;P&gt;  if sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;    delete t3 index v_index.&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;uline.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;display internal table T1&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;LOOP AT T3.&lt;/P&gt;&lt;P&gt;  WRITE:/ T3-F1, T3-F2.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-Anu&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Sep 2006 10:40:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-operations/m-p/1574403#M259355</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-09-18T10:40:16Z</dc:date>
    </item>
  </channel>
</rss>

