<?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 Loop using index read ( internal table) in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-using-index-read-internal-table/m-p/1060093#M91639</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 thought of impelementing loop at ITAB using read statements, Here it goes.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;REPORT Z_LOOP_IMPROVE.&lt;/P&gt;&lt;P&gt;DATA : T_OUTPUT TYPE STANDARD TABLE OF MARC WITH HEADER LINE,&lt;/P&gt;&lt;P&gt;L_TABIX TYPE SY-TABIX.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DEFINE ILOOP.&lt;/P&gt;&lt;P&gt; DO.&lt;/P&gt;&lt;P&gt;IF SY-INDEX EQ '1'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;READ TABLE &amp;amp;1 WITH KEY &amp;amp;2 = &amp;amp;3 BINARY SEARCH.&lt;/P&gt;&lt;P&gt;IF SY-SUBRC &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;EXIT.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ELSE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;L_TABIX = SY-TABIX + 1.&lt;/P&gt;&lt;P&gt;READ TABLE &amp;amp;1 INDEX L_TABIX.&lt;/P&gt;&lt;P&gt;IF SY-SUBRC NE 0 OR &amp;amp;1-&amp;amp;2 NE &amp;amp;3.&lt;/P&gt;&lt;P&gt;EXIT.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;END-OF-DEFINITION.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DEFINE IENDLOOP.&lt;/P&gt;&lt;P&gt;ENDDO.&lt;/P&gt;&lt;P&gt;END-OF-DEFINITION.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA : T1 TYPE I, T2 TYPE I.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT * FROM MARC INTO TABLE T_OUTPUT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SORT T_OUTPUT BY WERKS.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;GET RUN TIME FIELD T1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ILOOP T_OUTPUT WERKS '0001'.&lt;/P&gt;&lt;P&gt;WRITE : / T_OUTPUT-MATNR, T_OUTPUT-WERKS.&lt;/P&gt;&lt;P&gt;IENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;GET RUN TIME FIELD T2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;T2 = T2 - T1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;WRITE : / T2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*C----&lt;/P&gt;&lt;HR originaltext="------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But sadly it takes more time than a normal loop with &lt;/P&gt;&lt;P&gt;where condition.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;can anyone suggest some ideas to improve execution speed?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 08 Dec 2005 16:07:09 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2005-12-08T16:07:09Z</dc:date>
    <item>
      <title>Loop using index read ( internal table)</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-using-index-read-internal-table/m-p/1060093#M91639</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 thought of impelementing loop at ITAB using read statements, Here it goes.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;REPORT Z_LOOP_IMPROVE.&lt;/P&gt;&lt;P&gt;DATA : T_OUTPUT TYPE STANDARD TABLE OF MARC WITH HEADER LINE,&lt;/P&gt;&lt;P&gt;L_TABIX TYPE SY-TABIX.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DEFINE ILOOP.&lt;/P&gt;&lt;P&gt; DO.&lt;/P&gt;&lt;P&gt;IF SY-INDEX EQ '1'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;READ TABLE &amp;amp;1 WITH KEY &amp;amp;2 = &amp;amp;3 BINARY SEARCH.&lt;/P&gt;&lt;P&gt;IF SY-SUBRC &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;EXIT.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ELSE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;L_TABIX = SY-TABIX + 1.&lt;/P&gt;&lt;P&gt;READ TABLE &amp;amp;1 INDEX L_TABIX.&lt;/P&gt;&lt;P&gt;IF SY-SUBRC NE 0 OR &amp;amp;1-&amp;amp;2 NE &amp;amp;3.&lt;/P&gt;&lt;P&gt;EXIT.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;END-OF-DEFINITION.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DEFINE IENDLOOP.&lt;/P&gt;&lt;P&gt;ENDDO.&lt;/P&gt;&lt;P&gt;END-OF-DEFINITION.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA : T1 TYPE I, T2 TYPE I.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT * FROM MARC INTO TABLE T_OUTPUT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SORT T_OUTPUT BY WERKS.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;GET RUN TIME FIELD T1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ILOOP T_OUTPUT WERKS '0001'.&lt;/P&gt;&lt;P&gt;WRITE : / T_OUTPUT-MATNR, T_OUTPUT-WERKS.&lt;/P&gt;&lt;P&gt;IENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;GET RUN TIME FIELD T2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;T2 = T2 - T1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;WRITE : / T2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*C----&lt;/P&gt;&lt;HR originaltext="------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But sadly it takes more time than a normal loop with &lt;/P&gt;&lt;P&gt;where condition.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;can anyone suggest some ideas to improve execution speed?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Dec 2005 16:07:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-using-index-read-internal-table/m-p/1060093#M91639</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-12-08T16:07:09Z</dc:date>
    </item>
    <item>
      <title>Re: Loop using index read ( internal table)</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-using-index-read-internal-table/m-p/1060094#M91640</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just LOOP at the internal table.  Its doing the DO READ behind the LOOP anyway.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Rich Heilman&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Dec 2005 16:16:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-using-index-read-internal-table/m-p/1060094#M91640</guid>
      <dc:creator>RichHeilman</dc:creator>
      <dc:date>2005-12-08T16:16:20Z</dc:date>
    </item>
    <item>
      <title>Re: Loop using index read ( internal table)</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-using-index-read-internal-table/m-p/1060095#M91641</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can use a binary read to get the first record. Then read each record sequentially until you have proccessed all the records that meet your critera. You will have to have the internal table sorted so that the binary search and subsequent reads will work:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
      READ TABLE itab WITH KEY
        field = whatever
        BINARY SEARCH.
      IF sy-subrc = 0.
        itab_index = sy-tabix.
        DO.
          IF sy-subrc = 0.
            IF itab_data-field = whatever
              itab_index = itab_index + 1.
              READ TABLE itab_data INDEX itab_index.
            ELSE.
              EXIT.
            ENDIF.
          ELSE.
            EXIT.
          ENDIF.
        ENDDO.
      ENDIF.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Dec 2005 16:18:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-using-index-read-internal-table/m-p/1060095#M91641</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-12-08T16:18:45Z</dc:date>
    </item>
    <item>
      <title>Re: Loop using index read ( internal table)</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-using-index-read-internal-table/m-p/1060096#M91642</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;As long as a sorted table is out of scope, that is the correct way. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But maybe the macro-handling adds more time then simple loop where.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Instead of second read, you can also use a loop at itab from sy-index (in explicit programming). Personally I would avoid macros anyway, but making a function module will need extra time, too.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Christian&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Dec 2005 16:20:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-using-index-read-internal-table/m-p/1060096#M91642</guid>
      <dc:creator>christian_wohlfahrt</dc:creator>
      <dc:date>2005-12-08T16:20:02Z</dc:date>
    </item>
    <item>
      <title>Re: Loop using index read ( internal table)</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-using-index-read-internal-table/m-p/1060097#M91643</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;instead directly use loop...endloop &amp;amp; read statements with index.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at &amp;lt;inttable&amp;gt;.&lt;/P&gt;&lt;P&gt;  read &amp;lt;inttable2&amp;gt; index &amp;lt;integer&amp;gt;.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Dec 2005 16:24:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-using-index-read-internal-table/m-p/1060097#M91643</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-12-08T16:24:40Z</dc:date>
    </item>
    <item>
      <title>Re: Loop using index read ( internal table)</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-using-index-read-internal-table/m-p/1060098#M91644</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Guys, thanks a lot for ur response.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Dec 2005 16:35:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-using-index-read-internal-table/m-p/1060098#M91644</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-12-08T16:35:34Z</dc:date>
    </item>
    <item>
      <title>Re: Loop using index read ( internal table)</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-using-index-read-internal-table/m-p/1060099#M91645</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Note that this is useful only if both tables are large; otherwise, it's not worth the extra programming aggravation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Dec 2005 19:48:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-using-index-read-internal-table/m-p/1060099#M91645</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-12-08T19:48:48Z</dc:date>
    </item>
  </channel>
</rss>

