<?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: Hello experts read table statement is not working properly in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/hello-experts-read-table-statement-is-not-working-properly/m-p/2948488#M695145</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How you are sorting the itab_result.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sort it_matnr by matnr. " -&amp;gt; comment the sort&lt;/P&gt;&lt;P&gt;loop at itab_result.&lt;/P&gt;&lt;P&gt;read table it_matnr with key matnr = itab_result-matnr. " Comment  binary search.&lt;/P&gt;&lt;P&gt;.....&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now see the results.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Seshu&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 10 Oct 2007 17:07:26 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-10-10T17:07:26Z</dc:date>
    <item>
      <title>Hello experts read table statement is not working properly</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/hello-experts-read-table-statement-is-not-working-properly/m-p/2948487#M695144</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Experts.&lt;/P&gt;&lt;P&gt;my code is like this.&lt;/P&gt;&lt;P&gt;sort it_matnr by matnr.&lt;/P&gt;&lt;P&gt;loop at itab_result.&lt;/P&gt;&lt;P&gt;read table it_matnr with key matnr = itab_result-matnr  binary search.&lt;/P&gt;&lt;P&gt;.....&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;there are nearly 2000 records in it_matnr . The records which satisfy the above condition is there here in this internal table. But it is unable to read the record which matches the condition. One thing is that , there are more than one record with the same material. ie mblnr is different but material is the same. In it_matnr table i have only 1 field ie matnr ,so i need to compare only with the matnr.I also tried by sorting it_result by matnr but of no use. Then finally I used loop at where matnr = it_result-matnr , it is working fine. But due to performance reasons we should not use this. so please tell me what to do and correct the code.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Oct 2007 17:02:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/hello-experts-read-table-statement-is-not-working-properly/m-p/2948487#M695144</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-10T17:02:47Z</dc:date>
    </item>
    <item>
      <title>Re: Hello experts read table statement is not working properly</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/hello-experts-read-table-statement-is-not-working-properly/m-p/2948488#M695145</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How you are sorting the itab_result.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sort it_matnr by matnr. " -&amp;gt; comment the sort&lt;/P&gt;&lt;P&gt;loop at itab_result.&lt;/P&gt;&lt;P&gt;read table it_matnr with key matnr = itab_result-matnr. " Comment  binary search.&lt;/P&gt;&lt;P&gt;.....&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now see the results.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Seshu&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Oct 2007 17:07:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/hello-experts-read-table-statement-is-not-working-properly/m-p/2948488#M695145</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-10T17:07:26Z</dc:date>
    </item>
    <item>
      <title>Re: Hello experts read table statement is not working properly</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/hello-experts-read-table-statement-is-not-working-properly/m-p/2948489#M695146</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SORT it_matnr BY matnr.

LOOP AT itab_result.
  READ TABLE it_matnr
    WITH KEY matnr = itab_result-matnr
    BINARY SEARCH.
* Process record
  LOOP AT it_matnr FROM sy-tabix.
    IF it_matnr &amp;lt;&amp;gt; itab_result-matnr.
      EXIT.
    ENDIF.
* Process record
  ENDLOOP.

ENDLOOP.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Oct 2007 17:28:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/hello-experts-read-table-statement-is-not-working-properly/m-p/2948489#M695146</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-10T17:28:50Z</dc:date>
    </item>
    <item>
      <title>Re: Hello experts read table statement is not working properly</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/hello-experts-read-table-statement-is-not-working-properly/m-p/2948490#M695147</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 am sending you a sample code where i had writen for my program &lt;/P&gt;&lt;P&gt;there i did't faced any performance problem &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;sort it_sobid by objid.

  LOOP AT IT_SOBID INTO WA_SOBID." where otype eq s_otype and objid eq s_objid.

    READ TABLE IT_HRP1026 WITH KEY OBJID = WA_SOBID-SOBID OTYPE = WA_SOBID-SCLAS INTO WA_HRP1026.
    IF SY-SUBRC EQ 0.
      READ TABLE IT_HRP1000 WITH KEY OBJID = WA_SOBID-SOBID INTO WA_HRP1000.

      WA_OUTPUT-OBJID = WA_HRP1026-OBJID.
      WA_OUTPUT-BEGDA = WA_SOBID-BEGDA.
      WA_OUTPUT-ENDDA = WA_SOBID-ENDDA.
      WA_OUTPUT-AEDTM = WA_HRP1026-AEDTM.
      WA_OUTPUT-UNAME = WA_HRP1026-UNAME.

      APPEND WA_OUTPUT TO IT_OUTPUT.
      CLEAR WA_OUTPUT.
        ENDIF.
  ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;Reward if usefull&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Oct 2007 04:34:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/hello-experts-read-table-statement-is-not-working-properly/m-p/2948490#M695147</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-11T04:34:00Z</dc:date>
    </item>
    <item>
      <title>Re: Hello experts read table statement is not working properly</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/hello-experts-read-table-statement-is-not-working-properly/m-p/2948491#M695148</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;if the multiple entries are there, then it will change all the values which macthes the matnr. look for some different field which changes each time and has different value&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Shiva&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Oct 2007 04:35:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/hello-experts-read-table-statement-is-not-working-properly/m-p/2948491#M695148</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-11T04:35:56Z</dc:date>
    </item>
    <item>
      <title>Re: Hello experts read table statement is not working properly</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/hello-experts-read-table-statement-is-not-working-properly/m-p/2948492#M695149</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;     read statement suppress duplicate records..it reads only the first record when &lt;/P&gt;&lt;P&gt;      there are duplicate records.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;     hence you have to use  nested loops.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;     ie.    loop at itab_result.&lt;/P&gt;&lt;P&gt;               loop at it_matnr.&lt;/P&gt;&lt;P&gt;               endloop.&lt;/P&gt;&lt;P&gt;            endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;         if performance is taken into accout write where condition&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;        i.e., loop at itab_result.&lt;/P&gt;&lt;P&gt;               loop at it_matnr where matnr = itab_result-matnr.&lt;/P&gt;&lt;P&gt;               endloop.&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;&lt;/P&gt;&lt;P&gt;sree&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Oct 2007 04:43:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/hello-experts-read-table-statement-is-not-working-properly/m-p/2948492#M695149</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-11T04:43:26Z</dc:date>
    </item>
    <item>
      <title>Re: Hello experts read table statement is not working properly</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/hello-experts-read-table-statement-is-not-working-properly/m-p/2948493#M695150</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Shiva,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try this.&lt;/P&gt;&lt;P&gt;data : wa_itab_result like line of itab_result.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sort it_matnr by matnr.&lt;/P&gt;&lt;P&gt;loop at itab_result  into &amp;lt;b&amp;gt;wa_itab_result&amp;lt;/b&amp;gt;.&lt;/P&gt;&lt;P&gt;read table it_matnr with key matnr = &amp;lt;b&amp;gt;wa_itab_result-&amp;lt;/b&amp;gt;matnr binary search.&lt;/P&gt;&lt;P&gt;.....&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;Reward if Useful.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Chitra&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Oct 2007 04:45:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/hello-experts-read-table-statement-is-not-working-properly/m-p/2948493#M695150</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-11T04:45:31Z</dc:date>
    </item>
    <item>
      <title>Re: Hello experts read table statement is not working properly</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/hello-experts-read-table-statement-is-not-working-properly/m-p/2948494#M695151</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;Try with this following code,&lt;/P&gt;&lt;P&gt;sort it_matnr by matnr.&lt;/P&gt;&lt;P&gt;loop at itab_result.&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;Clear : it_matnr&amp;lt;/b&amp;gt;  " u should use always clear stat before READ, suppose if read statement fails it contains the previous read data.&lt;/P&gt;&lt;P&gt;read table it_matnr with key matnr = itab_result-matnr binary search.&lt;/P&gt;&lt;P&gt;.....&lt;/P&gt;&lt;P&gt;endloop&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if u using version above 4.7e use the following code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data : wa_itab_result like line of itab_result.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sort it_matnr by matnr.&lt;/P&gt;&lt;P&gt;loop at itab_result into wa_itab_result.&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;Clear : it_matnr&amp;lt;/b&amp;gt;  " u should use always clear stat before READ, suppose if read statement fails it contains the previous read data.&lt;/P&gt;&lt;P&gt;read table it_matnr with key matnr = wa_itab_result-matnr binary search.&lt;/P&gt;&lt;P&gt;.....&lt;/P&gt;&lt;P&gt;clear : itab_matnr.&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;&amp;lt;b&amp;gt;Reward with points if useful.&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Vijay&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Oct 2007 04:57:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/hello-experts-read-table-statement-is-not-working-properly/m-p/2948494#M695151</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-11T04:57:03Z</dc:date>
    </item>
    <item>
      <title>Re: Hello experts read table statement is not working properly</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/hello-experts-read-table-statement-is-not-working-properly/m-p/2948495#M695152</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;1. Make sure that the table IT_MATNR is not getting updated inside the loop. Because it will then destroy the sorting.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. Secondly, if there are multiple records in IT_MATNR for the same material then it will search for the first record encountered in binary algo. So it is advisable that you may provide further filter criteria if possible. check if ITAB_RESULT &amp;amp; IT_MATNR have any other matching field that can be put in filter criteria.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3.Thirdly, check if your requirement can be achieved by STABLE SORT.&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;SORT &amp;lt;itab&amp;gt; ... STABLE BY &amp;lt;f1&amp;gt;[ASCENDING/DESCENDING].&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It will allows you to perform a stable sort, that is, the relative sequence of lines that are unchanged by the sort is not changed. If you do not use the STABLE option, the sort sequence is not preserved. If you sort a table several times by the same key, the sequence of the table entries will change in each sort. However, a stable sort takes longer than an unstable sort. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;4. Lastly, you can use parallel cursor technique of multiple loops which is given below:&lt;/P&gt;&lt;P&gt;LOOP AT itab_result.&lt;/P&gt;&lt;P&gt;  READ TABLE it_matnr&lt;/P&gt;&lt;P&gt;    WITH KEY matnr = itab_result-matnr&lt;/P&gt;&lt;P&gt;    BINARY SEARCH.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Process record&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  LOOP AT it_matnr FROM sy-tabix.&lt;/P&gt;&lt;P&gt;    IF it_matnr &amp;lt;&amp;gt; itab_result-matnr.&lt;/P&gt;&lt;P&gt;      EXIT.&lt;/P&gt;&lt;P&gt;    ENDIF.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Process record based on yuor condition&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  ENDLOOP.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Oct 2007 10:18:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/hello-experts-read-table-statement-is-not-working-properly/m-p/2948495#M695152</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-10-11T10:18:18Z</dc:date>
    </item>
  </channel>
</rss>

