<?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: Read statement giving problem in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-statement-giving-problem/m-p/4522787#M1069230</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;READ TABLE lt_mseg INTO lw_mseg WITH KEY mblnr = lw_mkpf-mblnr binary search&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;here ur fetching only one record.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;LOOP AT lt_mseg INTO lw_mseg WHERE mblnr EQ v_mkpf.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In this u may get no.of records.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SO continue with below statement only.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 20 Sep 2008 07:59:05 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-09-20T07:59:05Z</dc:date>
    <item>
      <title>Read statement giving problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-statement-giving-problem/m-p/4522785#M1069228</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear Experts,&lt;/P&gt;&lt;P&gt;I am making monthly consumption report, In which i am getting monthly data column wise for different month , here firstly i am fetching header mblnr  date according to date from mkpf then i am fetching data from mseg.....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have same mblnr in both tables..... Now i am using read statement like this.......&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sort lt_mkpf by mblnr.&lt;/P&gt;&lt;P&gt;SORT lt_mseg BY mblnr.&lt;/P&gt;&lt;P&gt;LOOP AT lt_mkpf INTO lw_mkpf.&lt;/P&gt;&lt;P&gt;READ TABLE lt_mseg INTO lw_mseg WITH KEY mblnr = lw_mkpf-mblnr&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;                                            mjahr = lw_mkpf-mjahr&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;                                                    BINARY SEARCH.&lt;/P&gt;&lt;P&gt;When I am debugging i am getting data in lw_mkpf but sy-subrc = 4 is coming  and getting wrong data in final table by using these above statements.......... &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;where as if i am using loop like this: &lt;/P&gt;&lt;P&gt;SORT lt_mkpf BY mblnr.&lt;/P&gt;&lt;P&gt;SORT lt_mseg BY mblnr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT lt_mkpf INTO lw_mkpf.&lt;/P&gt;&lt;P&gt;v_mkpf = lw_mkpf-mblnr.&lt;/P&gt;&lt;P&gt;LOOP AT lt_mseg INTO lw_mseg WHERE mblnr EQ v_mkpf.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;with this i am getting right data........ But it takes lot of time to execute..........&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can you please guide me am i using read statement by wrong method. which one is the correct method which one shoul be used.........&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 20 Sep 2008 07:47:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-statement-giving-problem/m-p/4522785#M1069228</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-09-20T07:47:32Z</dc:date>
    </item>
    <item>
      <title>Re: Read statement giving problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-statement-giving-problem/m-p/4522786#M1069229</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 like this.... dont sort lt_mkpf table and then try&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
SORT lt_mseg BY mblnr.
LOOP AT lt_mkpf INTO lw_mkpf.
READ TABLE lt_mseg INTO lw_mseg WITH KEY mblnr = lw_mkpf-mblnr binary search.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Hope it will helps&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 20 Sep 2008 07:57:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-statement-giving-problem/m-p/4522786#M1069229</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-09-20T07:57:10Z</dc:date>
    </item>
    <item>
      <title>Re: Read statement giving problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-statement-giving-problem/m-p/4522787#M1069230</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;READ TABLE lt_mseg INTO lw_mseg WITH KEY mblnr = lw_mkpf-mblnr binary search&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;here ur fetching only one record.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;LOOP AT lt_mseg INTO lw_mseg WHERE mblnr EQ v_mkpf.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In this u may get no.of records.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SO continue with below statement only.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 20 Sep 2008 07:59:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-statement-giving-problem/m-p/4522787#M1069230</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-09-20T07:59:05Z</dc:date>
    </item>
    <item>
      <title>Re: Read statement giving problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-statement-giving-problem/m-p/4522788#M1069231</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi shelly,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As to say both are same but ,&lt;/P&gt;&lt;P&gt;In first you used ... year condition (mjahr.)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As to say year is not requried for mkpf to mseg. &lt;/P&gt;&lt;P&gt;mkpf is header and mseg is Item wise ....When ever user creats GR in MIGO .. automatically both tables will trigger ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;waiting for rewards...&lt;/P&gt;&lt;P&gt;From &lt;/P&gt;&lt;P&gt;Maddy .&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 20 Sep 2008 08:42:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-statement-giving-problem/m-p/4522788#M1069231</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-09-20T08:42:14Z</dc:date>
    </item>
    <item>
      <title>Re: Read statement giving problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-statement-giving-problem/m-p/4522789#M1069232</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;while Sorting your Table, Sort it with both MBLNR and MJAHR.&lt;/P&gt;&lt;P&gt;Sure this will solve your issue.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Refer the following SAP Help Content.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;standard tables are subject to a linear search. If the addition BINARY SEARCH is specified, the search is binary instead of linear. This considerably reduces the runtime of the search for larger tables (from approximately 100 entries upwards). For the binary search, the table must be sorted by the specified search key in ascending order. Otherwise the search will not find the correct row.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 20 Sep 2008 08:46:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-statement-giving-problem/m-p/4522789#M1069232</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-09-20T08:46:30Z</dc:date>
    </item>
    <item>
      <title>Re: Read statement giving problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-statement-giving-problem/m-p/4522790#M1069233</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey Dude, sorry my previous post was not presentable,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Refer the SAP help content now, from below.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;standard tables are subject to a linear search. If the addition 
BINARY SEARCH is specified, the search is binary instead of 
linear. This considerably reduces the runtime of the search for 
larger tables (from approximately 100 entries upwards). For the
 binary search, the table must be sorted by the specified 
search key in ascending order. Otherwise the search will not
 find the correct row.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 20 Sep 2008 08:50:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-statement-giving-problem/m-p/4522790#M1069233</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-09-20T08:50:50Z</dc:date>
    </item>
    <item>
      <title>Re: Read statement giving problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-statement-giving-problem/m-p/4522791#M1069234</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Shelly,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To solve the issue of read table being failed, Sort the internal table by mblnr and mjahr. say sort lt_mseg by mblnr mjahr but read the internal table mseg will give you only one data. What about the other line items. MSEG is material document line item table. So for one record in MKPF there can be more than one record in MSEG. So to consider all the line items, you need to loop on the MSEG internal table instead of read table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT lt_mkpf INTO lw_mkpf.&lt;/P&gt;&lt;P&gt;v_mkpf = lw_mkpf-mblnr.&lt;/P&gt;&lt;P&gt;LOOP AT lt_mseg INTO lw_mseg WHERE mblnr EQ v_mkpf. &lt;/P&gt;&lt;P&gt;This statement will take time and create performance issue. So rewrite the statement as &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT lt_mseg INTO lw_mseg. &lt;/P&gt;&lt;P&gt;read table lt_mkpf with key lw_mkpf binary search.&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;Farzan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 21 Sep 2008 04:25:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-statement-giving-problem/m-p/4522791#M1069234</guid>
      <dc:creator>former_member137336</dc:creator>
      <dc:date>2008-09-21T04:25:13Z</dc:date>
    </item>
    <item>
      <title>Re: Read statement giving problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/read-statement-giving-problem/m-p/4522792#M1069235</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If the second one is working, try using the following.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT lt_mkpf INTO lw_mkpf.&lt;/P&gt;&lt;P&gt;v_mkpf = lw_mkpf-mblnr.&lt;/P&gt;&lt;P&gt;READ TABLE lt_mseg INTO lw_mseg WITH KEY mblnr = v_mkpf.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Sep 2008 10:07:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/read-statement-giving-problem/m-p/4522792#M1069235</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-09-22T10:07:37Z</dc:date>
    </item>
  </channel>
</rss>

