<?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: Better performance for program in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/better-performance-for-program/m-p/4009115#M957771</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Every time you do a READ without the BINARY SEARCH option, it's like doing:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;LOOP AT itab WHERE ...
  EXIT.
ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Adding the BINARY SEARCH will definitely help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 17 Jun 2008 15:59:19 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-06-17T15:59:19Z</dc:date>
    <item>
      <title>Better performance for program</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/better-performance-for-program/m-p/4009111#M957767</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;I have a program which its execution is 'ok' if there are few record (for example 250), otherwise, system show a message of time out.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In this case, what I should do to get better performance for program?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;These are code lines for data selection&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
SELECT ZLOTE BUKRS ANLN1 INVNR ORD41 ORD42 ORD43 ORD44 FROM zanla1
         INTO TABLE ti_zanla1
         WHERE INVNR IN p_invnr.

 SORT ti_zanla1 BY INVNR.

  LOOP AT ti_zanla1 INTO wa_zanla1.

    READ TABLE ti_zinvnr WITH KEY BUKRS = wa_zanla1-bukrs
                                   INVNR = wa_zanla1-invnr
                          ASSIGNING &amp;lt;zinvnr&amp;gt;.

    IF SY-SUBRC = 0.

      READ TABLE it_invnr_control WITH KEY ZLOTE = &amp;lt;zinvnr&amp;gt;-ZLOTE ASSIGNING &amp;lt;zcontrol_serial&amp;gt;.
      IF sy-subrc = 0.
        it_output-ZFECHAEC  = &amp;lt;zcontrol_serial&amp;gt;-ZFECHAEC.
        it_output-ZHORAEC   = &amp;lt;zcontrol_serial&amp;gt;-ZHORAEC.
      ENDIF.

      it_output-EBELN    = &amp;lt;zinvnr&amp;gt;-EBELN.
      it_output-BISMT    = &amp;lt;zinvnr&amp;gt;-BISMT.

      READ TABLE ti_zcontrol_anla1 WITH KEY ZLOTE = wa_zanla1-ZLOTE ASSIGNING &amp;lt;zcontrol_anla1&amp;gt;.
      IF sy-subrc = 0.
        it_output-FECHAREC = &amp;lt;zcontrol_anla1&amp;gt;-ZFECHAEC.
      ENDIF.

      it_output-ZLOTE   = wa_zanla1-ZLOTE.
*        it_output-BUKRS   = wa_zanla1-BUKRS.
      it_output-ANLN1   = wa_zanla1-ANLN1.
      it_output-INVNR   = wa_zanla1-INVNR.

      IF wa_zanla1-INVNR = ZINVNR.
        it_output-TOTIN01 = 0.
      ELSE.
        it_output-TOTIN01 = 1.
      ENDIF.


      it_output-ORD41   = wa_zanla1-ORD41.

      READ TABLE ti_t087t WITH KEY ordnr = '1' ord4x = ti_salida-ord41.
      it_output-T_ORD41 = ti_t087t-ordtx.

      it_output-ORD42   = wa_zanla1-ORD42.
      READ TABLE ti_t087t WITH KEY ordnr = '2' ord4x = ti_salida-ord42.
      it_output-T_ORD42 = ti_t087t-ordtx.

      it_output-ORD43   = wa_zanla1-ORD43.
      READ TABLE ti_t087t WITH KEY ordnr = '3' ord4x = ti_salida-ord43.
      it_output-T_ORD43 = ti_t087t-ordtx.

      it_output-ORD44   = wa_zanla1-ORD44.
      READ TABLE ti_t087t WITH KEY ordnr = '4' ord4x = ti_salida-ord44.
      it_output-T_ORD44 =  ti_t087t-ordtx.
*        it_output-STATUS  = wa_zanla1-STATUS.
      APPEND it_output.
      CLEAR it_output.
    ENDIF.  

  ENDLOOP.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Jun 2008 15:46:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/better-performance-for-program/m-p/4009111#M957767</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-06-17T15:46:31Z</dc:date>
    </item>
    <item>
      <title>Re: Better performance for program</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/better-performance-for-program/m-p/4009112#M957768</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sort the internal tables and then use the BINARY SEARCH option of the READ statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Jun 2008 15:53:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/better-performance-for-program/m-p/4009112#M957768</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-06-17T15:53:55Z</dc:date>
    </item>
    <item>
      <title>Re: Better performance for program</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/better-performance-for-program/m-p/4009113#M957769</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Rob, I'll test and let you know.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Jun 2008 15:56:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/better-performance-for-program/m-p/4009113#M957769</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-06-17T15:56:19Z</dc:date>
    </item>
    <item>
      <title>Re: Better performance for program</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/better-performance-for-program/m-p/4009114#M957770</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How large is table zanla1?&lt;/P&gt;&lt;P&gt;Is INVNR the primary or a secondary key of that table?&lt;/P&gt;&lt;P&gt;Thomas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Jun 2008 15:59:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/better-performance-for-program/m-p/4009114#M957770</guid>
      <dc:creator>ThomasZloch</dc:creator>
      <dc:date>2008-06-17T15:59:05Z</dc:date>
    </item>
    <item>
      <title>Re: Better performance for program</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/better-performance-for-program/m-p/4009115#M957771</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Every time you do a READ without the BINARY SEARCH option, it's like doing:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;LOOP AT itab WHERE ...
  EXIT.
ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Adding the BINARY SEARCH will definitely help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Jun 2008 15:59:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/better-performance-for-program/m-p/4009115#M957771</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-06-17T15:59:19Z</dc:date>
    </item>
    <item>
      <title>Re: Better performance for program</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/better-performance-for-program/m-p/4009116#M957772</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Thomas&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;How large is table zanla1?&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;397.312 in DEV, 437.905 PRD&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Is INVNR the primary or a secondary key of that table?&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;INVNR is the primary&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Jun 2008 16:03:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/better-performance-for-program/m-p/4009116#M957772</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-06-17T16:03:31Z</dc:date>
    </item>
    <item>
      <title>Re: Better performance for program</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/better-performance-for-program/m-p/4009117#M957773</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;sounds good, so stick with Rob's suggestions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A small additional gain might be possible by replacing&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;LOOP AT ti_zanla1 INTO wa_zanla1.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;with&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;LOOP AT ti_zanla1 ASSIGNING &amp;lt;zanla1&amp;gt;.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and dependent statements of course.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thomas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Jun 2008 16:06:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/better-performance-for-program/m-p/4009117#M957773</guid>
      <dc:creator>ThomasZloch</dc:creator>
      <dc:date>2008-06-17T16:06:36Z</dc:date>
    </item>
    <item>
      <title>Re: Better performance for program</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/better-performance-for-program/m-p/4009118#M957774</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;
SORT ti_zanla1 BY INVNR.
 
  LOOP AT ti_zanla1 INTO wa_zanla1.
 
    READ TABLE ti_zinvnr WITH KEY BUKRS = wa_zanla1-bukrs
                                   INVNR = wa_zanla1-invnr
                          ASSIGNING &amp;lt;zinvnr&amp;gt;.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would recommend you to use Sorted tables for all tables which are used with the READs inside the LOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If this is not possible, then sort the standard table before the LOOP starts and use BINARY SEARCH.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There is no real advantage that the large table ti_zanla1 is sorted, the LOOP processes anyway the complete LOOP. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Maybe there is some other logic, which profits of the sort. The APPEND could be such a logic, if the result-table should also be sorted then it makes sense to have&lt;/P&gt;&lt;P&gt;the sort on the LOOP-table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Siegfried&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Jun 2008 09:04:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/better-performance-for-program/m-p/4009118#M957774</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-06-18T09:04:59Z</dc:date>
    </item>
  </channel>
</rss>

