<?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: performance in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance/m-p/1582487#M262741</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I guess this should be select single&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;loop at mkpftbl.
&amp;lt;b&amp;gt;select single&amp;lt;/b&amp;gt; zeile matnr werks charg menge from mseg
into (mseg-zeile, mseg-matnr, mseg-werks, mseg-charg,
mseg-menge)
where mblnr eq mkpftbl-wmblnr and mjahr eq mkpftbl-wmjahr and
bwart eq cbwart and werks eq splant.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 09 Oct 2006 13:29:10 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2006-10-09T13:29:10Z</dc:date>
    <item>
      <title>performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance/m-p/1582484#M262738</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;could anyone suggest me the changes to be done in the following code performance wise.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;form getdata.&lt;/P&gt;&lt;P&gt;data: wrecord type i.&lt;/P&gt;&lt;P&gt;data: wtime type t.&lt;/P&gt;&lt;P&gt;data: wtoday type d.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;move sy-datum to wtoday.&lt;/P&gt;&lt;P&gt;move sy-uzeit to wtime.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if wtime eq '000000'. wtoday = wtoday - 1. endif.&lt;/P&gt;&lt;P&gt;status = 1.&lt;/P&gt;&lt;P&gt;if sy-batch = 'X'.&lt;/P&gt;&lt;P&gt;select mblnr mjahr bldat cputm from mkpf into table mkpftbl&lt;/P&gt;&lt;P&gt;where bldat eq wtoday and tcode2 eq ctcode2.&lt;/P&gt;&lt;P&gt;else.&lt;/P&gt;&lt;P&gt;select mblnr mjahr bldat cputm from mkpf into table mkpftbl&lt;/P&gt;&lt;P&gt;where mblnr in mblnr and mjahr in mjahr and tcode2 eq ctcode2.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;describe table mkpftbl lines wrecord.&lt;/P&gt;&lt;P&gt;if wrecord &amp;gt; 0.&lt;/P&gt;&lt;P&gt;loop at mkpftbl.&lt;/P&gt;&lt;P&gt;select zeile matnr werks charg menge from mseg&lt;/P&gt;&lt;P&gt;into (mseg-zeile, mseg-matnr, mseg-werks, mseg-charg,&lt;/P&gt;&lt;P&gt;mseg-menge)&lt;/P&gt;&lt;P&gt;where mblnr eq mkpftbl-wmblnr and mjahr eq mkpftbl-wmjahr and&lt;/P&gt;&lt;P&gt;bwart eq cbwart and werks eq splant.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;move mkpftbl-wmblnr to msegtbl-wmblnr.&lt;/P&gt;&lt;P&gt;move mkpftbl-wmjahr to msegtbl-wmjahr.&lt;/P&gt;&lt;P&gt;move mkpftbl-wbldat to msegtbl-wbldat.&lt;/P&gt;&lt;P&gt;move mkpftbl-wcputm to msegtbl-wcputm.&lt;/P&gt;&lt;P&gt;move mseg-zeile to msegtbl-wzeile.&lt;/P&gt;&lt;P&gt;move mseg-matnr to msegtbl-wmatnr.&lt;/P&gt;&lt;P&gt;move mseg-werks to msegtbl-wwerks.&lt;/P&gt;&lt;P&gt;move mseg-charg to msegtbl-wcharg.&lt;/P&gt;&lt;P&gt;move mseg-menge to msegtbl-wmenge.&lt;/P&gt;&lt;P&gt;append msegtbl.&lt;/P&gt;&lt;P&gt;clear msegtbl.&lt;/P&gt;&lt;P&gt;endselect.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;status = 0.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;endform. "GetData&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Oct 2006 13:25:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance/m-p/1582484#M262738</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-10-09T13:25:10Z</dc:date>
    </item>
    <item>
      <title>Re: performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance/m-p/1582485#M262739</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi Srini,&lt;/P&gt;&lt;P&gt;1. Replace all the move statement with assignment operator.&lt;/P&gt;&lt;P&gt;2. Try Including all the primary keys in your select statement ..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Santosh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Oct 2006 13:28:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance/m-p/1582485#M262739</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-10-09T13:28:11Z</dc:date>
    </item>
    <item>
      <title>Re: performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance/m-p/1582486#M262740</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This part of the code as to be changed:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at mkpftbl.&lt;/P&gt;&lt;P&gt;select zeile matnr werks charg menge from mseg&lt;/P&gt;&lt;P&gt;into (mseg-zeile, mseg-matnr, mseg-werks, mseg-charg,&lt;/P&gt;&lt;P&gt;mseg-menge)&lt;/P&gt;&lt;P&gt;where mblnr eq mkpftbl-wmblnr and mjahr eq mkpftbl-wmjahr and&lt;/P&gt;&lt;P&gt;bwart eq cbwart and werks eq splant.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;move mkpftbl-wmblnr to msegtbl-wmblnr.&lt;/P&gt;&lt;P&gt;move mkpftbl-wmjahr to msegtbl-wmjahr.&lt;/P&gt;&lt;P&gt;move mkpftbl-wbldat to msegtbl-wbldat.&lt;/P&gt;&lt;P&gt;move mkpftbl-wcputm to msegtbl-wcputm.&lt;/P&gt;&lt;P&gt;move mseg-zeile to msegtbl-wzeile.&lt;/P&gt;&lt;P&gt;move mseg-matnr to msegtbl-wmatnr.&lt;/P&gt;&lt;P&gt;move mseg-werks to msegtbl-wwerks.&lt;/P&gt;&lt;P&gt;move mseg-charg to msegtbl-wcharg.&lt;/P&gt;&lt;P&gt;move mseg-menge to msegtbl-wmenge.&lt;/P&gt;&lt;P&gt;append msegtbl.&lt;/P&gt;&lt;P&gt;clear msegtbl.&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;Change with &amp;lt;b&amp;gt;for all entries in mkpftbl&amp;lt;/b&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select zeile matnr werks charg menge from mseg&lt;/P&gt;&lt;P&gt;into corresponding fields of table msegtbl&lt;/P&gt;&lt;P&gt;for all entries in mkpftbl&lt;/P&gt;&lt;P&gt;where mblnr eq mkpftbl-wmblnr and mjahr eq mkpftbl-wmjahr and&lt;/P&gt;&lt;P&gt;bwart eq cbwart and werks eq splant.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;PRakash.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Oct 2006 13:28:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance/m-p/1582486#M262740</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-10-09T13:28:47Z</dc:date>
    </item>
    <item>
      <title>Re: performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance/m-p/1582487#M262741</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I guess this should be select single&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;loop at mkpftbl.
&amp;lt;b&amp;gt;select single&amp;lt;/b&amp;gt; zeile matnr werks charg menge from mseg
into (mseg-zeile, mseg-matnr, mseg-werks, mseg-charg,
mseg-menge)
where mblnr eq mkpftbl-wmblnr and mjahr eq mkpftbl-wmjahr and
bwart eq cbwart and werks eq splant.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Oct 2006 13:29:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance/m-p/1582487#M262741</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-10-09T13:29:10Z</dc:date>
    </item>
    <item>
      <title>Re: performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance/m-p/1582488#M262742</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;1. Replace the loop at mkpftbl...endloop with &lt;/P&gt;&lt;P&gt;select mblnr mjahr zeile matnr werks charg menge from mseg into corresponding fields of table msegtbl&lt;/P&gt;&lt;P&gt;for all enteries in mkpftbl&lt;/P&gt;&lt;P&gt;where mblnr eq mkpftbl-wmblnr and mjahr eq mkpftbl-wmjahr and&lt;/P&gt;&lt;P&gt;bwart eq cbwart and werks eq splant.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at msegtbl.&lt;/P&gt;&lt;P&gt;  read table mkpftbl with key wmblnr = msegtbl-mblnr&lt;/P&gt;&lt;P&gt;  and wmjahr = msegtbl-mjahr.&lt;/P&gt;&lt;P&gt;  move mkpftbl-wbldat to msegtbl-wbldat.&lt;/P&gt;&lt;P&gt;  move mkpftbl-wcputm to msegtbl-wcputm.&lt;/P&gt;&lt;P&gt;  modify msegtbl.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Oct 2006 14:13:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance/m-p/1582488#M262742</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-10-09T14:13:05Z</dc:date>
    </item>
    <item>
      <title>Re: performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance/m-p/1582489#M262743</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your problem is caused by the fact that you are not using an index in your first SELECT. Rather than:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
where bldat eq wtoday &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;see if you can use:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;where &amp;lt;b&amp;gt;budat&amp;lt;/b&amp;gt; eq wtoday &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; There is an index on budat in MKPF but not bldat.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Oct 2006 16:56:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance/m-p/1582489#M262743</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-10-09T16:56:46Z</dc:date>
    </item>
    <item>
      <title>Re: performance</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance/m-p/1582490#M262744</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As per your code you are fetching data from MSEG into loop which is a wrong way from performance point of view. You should not fetch data from DB in loop but instead use for all entries statement. Comment the code for fetching data in loop shown below&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at mkpftbl.&lt;/P&gt;&lt;P&gt;select zeile matnr werks charg menge from mseg&lt;/P&gt;&lt;P&gt;into (mseg-zeile, mseg-matnr, mseg-werks, mseg-charg,&lt;/P&gt;&lt;P&gt;mseg-menge)&lt;/P&gt;&lt;P&gt;where mblnr eq mkpftbl-wmblnr and mjahr eq mkpftbl-wmjahr and&lt;/P&gt;&lt;P&gt;bwart eq cbwart and werks eq splant.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can use the following statement:&lt;/P&gt;&lt;P&gt;You can create an internal table itab_mseg with the fields you want to fetch from msge (mblnr mjahr zeile matnr werks charg menge ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if not mkpftbl[] is initial.&lt;/P&gt;&lt;P&gt;select mblnr mjahr zeile matnr werks charg menge &lt;/P&gt;&lt;P&gt;from mseg&lt;/P&gt;&lt;P&gt;into table itab_mseg&lt;/P&gt;&lt;P&gt;for all entries in mkpftbl&lt;/P&gt;&lt;P&gt;where mblnr eq mkpftbl-wmblnr&lt;/P&gt;&lt;P&gt;and mjahr eq mkpftbl-wmjahr&lt;/P&gt;&lt;P&gt;and bwart eq cbwart&lt;/P&gt;&lt;P&gt;and werks eq splant.&lt;/P&gt;&lt;P&gt;if sy-subrc eq 0.&lt;/P&gt;&lt;P&gt;sort itab_mseg by mblnr mjahr zeile.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Here you might be having duplicate records, so u have to decide whether u want to delete the duplicate records or want to play with all of these&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then here you can Read the records one by one using read statement in binary search mode.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at mkpftbl.&lt;/P&gt;&lt;P&gt;clear itab_mseg.&lt;/P&gt;&lt;P&gt;read table itab_mseg with key mblnr = mkpftbl-mblnr&lt;/P&gt;&lt;P&gt;mjahr = mkpftbl-mjahr&lt;/P&gt;&lt;P&gt;binary search.&lt;/P&gt;&lt;P&gt;if s-subrc eq 0.&lt;/P&gt;&lt;P&gt;here u can move entries from itab_mseg header to msegtbl and append it.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Oct 2006 21:15:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance/m-p/1582490#M262744</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-10-09T21:15:32Z</dc:date>
    </item>
  </channel>
</rss>

