<?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: how can i improve this code ? in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-can-i-improve-this-code/m-p/1471744#M221667</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thanks,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Guillaume Garcia.. can u demonstrate with an example mapped on my problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks..&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 28 Jul 2006 21:02:06 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2006-07-28T21:02:06Z</dc:date>
    <item>
      <title>how can i improve this code ?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-can-i-improve-this-code/m-p/1471740#M221663</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;DATA: t_bkpf TYPE bkpf.&lt;/P&gt;&lt;P&gt;DATA: t_bseg type bseg_t.&lt;/P&gt;&lt;P&gt;DATA: wa_bseg like line of t_bseg.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select * from bkpf into t_bkpf where document type ='KZ' and bldat in s_bldat.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select single * from bseg into wa_bseg where belnr = t_bkpf-belnr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;append wa_bseg to t_bseg.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endselect. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at t_bseg into wa_bseg.&lt;/P&gt;&lt;P&gt;  at new belnr.&lt;/P&gt;&lt;P&gt;     if wa_bseg-koart EQ 'K'.&lt;/P&gt;&lt;P&gt;        // pick vendor wrbtr &lt;/P&gt;&lt;P&gt;     else&lt;/P&gt;&lt;P&gt;       // pick other line item's wrbtr&lt;/P&gt;&lt;P&gt;     endif.&lt;/P&gt;&lt;P&gt;  endat.&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;i am guessing my select statements arnt efficient performance wise, secondly in the loop when i use  'at new belnr' it aint showing my any values  whereas i get all the vendors(KOART EQ 'K') when i dont use 'at new belnr' .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;why is this so and how can i make the code efficient ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Shehryar&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Jul 2006 20:37:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-can-i-improve-this-code/m-p/1471740#M221663</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-07-28T20:37:46Z</dc:date>
    </item>
    <item>
      <title>Re: how can i improve this code ?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-can-i-improve-this-code/m-p/1471741#M221664</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Don't to do a SELECT inside another one, instead us FOR ALL ENTRIES.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select * from bkpf into t_bkpf where document type ='KZ' and bldat in s_bldat.&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;&lt;/P&gt;&lt;P&gt;if NOT t_bkpf[] is initial.&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;select * from bseg &amp;lt;b&amp;gt;&lt;/P&gt;&lt;P&gt;for all entries in t_bkpf&lt;/P&gt;&lt;P&gt;append corresponding fields of t_bseg&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;into wa_bseg where belnr = t_bkpf-belnr.&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;endif.&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Ravi&lt;/P&gt;&lt;P&gt;Note : Please mark all the helpful answers&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Jul 2006 20:43:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-can-i-improve-this-code/m-p/1471741#M221664</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-07-28T20:43:27Z</dc:date>
    </item>
    <item>
      <title>Re: how can i improve this code ?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-can-i-improve-this-code/m-p/1471742#M221665</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;change the second select statment as below.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select single * from bseg into table t_bseg where belnr = t_bkpf-belnr.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Jul 2006 20:43:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-can-i-improve-this-code/m-p/1471742#M221665</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-07-28T20:43:44Z</dc:date>
    </item>
    <item>
      <title>Re: how can i improve this code ?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-can-i-improve-this-code/m-p/1471743#M221666</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;Possible hints for performance optimisation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;SELECT&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;1) Try using a JOIN for the selection on 2 different tables&lt;/P&gt;&lt;P&gt;2) Do not use '*' but specify only the fields you really use afterwards in the processing&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;LOOP&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;1) Field-symbols can improve performance significantly&lt;/P&gt;&lt;P&gt;   LOOP AT ... INTO ... is less efficient than LOOP AT ... ASSIGNING ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To check this, use transaction SE30 to benchmark the different solutions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Guillaume&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Jul 2006 20:44:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-can-i-improve-this-code/m-p/1471743#M221666</guid>
      <dc:creator>guillaume-hrc</dc:creator>
      <dc:date>2006-07-28T20:44:04Z</dc:date>
    </item>
    <item>
      <title>Re: how can i improve this code ?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-can-i-improve-this-code/m-p/1471744#M221667</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thanks,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Guillaume Garcia.. can u demonstrate with an example mapped on my problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks..&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Jul 2006 21:02:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-can-i-improve-this-code/m-p/1471744#M221667</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-07-28T21:02:06Z</dc:date>
    </item>
    <item>
      <title>Re: how can i improve this code ?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-can-i-improve-this-code/m-p/1471745#M221668</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;what can u guys say to my second query i.e the 'at new belnr' one ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Shehryar&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Jul 2006 21:05:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-can-i-improve-this-code/m-p/1471745#M221668</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-07-28T21:05:41Z</dc:date>
    </item>
    <item>
      <title>Re: how can i improve this code ?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-can-i-improve-this-code/m-p/1471746#M221669</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;1.Dont read all the fields from the table unless it is required in your program.&lt;/P&gt;&lt;P&gt;This will tremendously improve your performance.&lt;/P&gt;&lt;P&gt;2.Make use of the key fields of the table wherever possible&lt;/P&gt;&lt;P&gt;In your scenario you could use the fields BUKRS,BELNR,GJAHR of the table BKPF in the WHERE Clause rather than &lt;/P&gt;&lt;P&gt;other fields.This will improve your performance a lot..&lt;/P&gt;&lt;P&gt;3.As BSEG is a cluster table it will cause performance problem in most cases.So try to read&lt;/P&gt;&lt;P&gt;the required fields from it rather than reading all the fields.Again Make use of the key fields in the WHERE Clause&lt;/P&gt;&lt;P&gt;here too to improve the performance..&lt;/P&gt;&lt;P&gt;4.Remove SELECT..ENDSELECT and replace it with FOR ALL ENTRIES to improve the performance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Abdul Hakim&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mark all useful answers..&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Jul 2006 21:09:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-can-i-improve-this-code/m-p/1471746#M221669</guid>
      <dc:creator>abdul_hakim</dc:creator>
      <dc:date>2006-07-28T21:09:55Z</dc:date>
    </item>
    <item>
      <title>Re: how can i improve this code ?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-can-i-improve-this-code/m-p/1471747#M221670</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ravi, is this a correct code snippet u advised me.?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select * from bkpf into t_bkpf where document type ='KZ' and bldat in s_bldat.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;if NOT t_bkpf[] is initial.&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;select * from bseg &lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;for all entries in t_bkpf&lt;/P&gt;&lt;P&gt;append corresponding fields of t_bseg&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;into wa_bseg where belnr = t_bkpf-belnr.&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;endif.&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;is it in the correct order .. are they two separate codes ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 Aug 2006 06:43:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-can-i-improve-this-code/m-p/1471747#M221670</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-08-01T06:43:24Z</dc:date>
    </item>
    <item>
      <title>Re: how can i improve this code ?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-can-i-improve-this-code/m-p/1471748#M221671</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Include BUKRS BLDAT BSTAT in your first selection query. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select * from bkpf into t_bkpf &lt;/P&gt;&lt;P&gt;where bukrs = '0001'&lt;/P&gt;&lt;P&gt;and bldat in s_bldat&lt;/P&gt;&lt;P&gt;and bstat = ' '&lt;/P&gt;&lt;P&gt;and document type ='KZ' .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if not sy-dbcnt is initial.&lt;/P&gt;&lt;P&gt;select * from bseg &lt;/P&gt;&lt;P&gt;for all entries of t_bkpf &lt;/P&gt;&lt;P&gt;into t_bseg &lt;/P&gt;&lt;P&gt;where bukrs = t_bkpf-bukrs&lt;/P&gt;&lt;P&gt;and   belnr = t_bkpf-belnr&lt;/P&gt;&lt;P&gt;and   gjahr = t_bkpf-gjahr.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Naimesh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 Aug 2006 06:47:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-can-i-improve-this-code/m-p/1471748#M221671</guid>
      <dc:creator>naimesh_patel</dc:creator>
      <dc:date>2006-08-01T06:47:56Z</dc:date>
    </item>
  </channel>
</rss>

