<?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: Select Query not workin as expected in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-query-not-workin-as-expected/m-p/2718050#M630490</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Imran,&lt;/P&gt;&lt;P&gt;please check the SQL performance in transaction ST05 &amp;gt; "Explaine one SQL request" for this slightly modified statement:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
select mblnr, mjahr, zeile, bwart, matnr, werks, charg, lifnr, 
shkzg, bwtar, menge, meins, ebeln, aufnr bukrs, prctr 
from mseg
where 
(
mblnr = '1' and 
mjahr = '2' and 
bwart in ('1', '2') and 
werks in ('1', '2') and 
bukrs in ('1', '2')
)
or
(
mblnr = '1' and 
mjahr = '2' and 
bwart in ('1', '2') and 
werks in ('1', '2') and 
bukrs in ('1', '2')
)
or
(
mblnr = '1' and 
mjahr = '2' and 
bwart in ('1', '2') and 
werks in ('1', '2') and 
bukrs in ('1', '2')
)
or
(
mblnr = '1' and 
mjahr = '2' and 
bwart in ('1', '2') and 
werks in ('1', '2') and 
bukrs in ('1', '2')
)
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please answer back with the results. Best regards,&lt;/P&gt;&lt;P&gt;Alvaro&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 29 Aug 2007 07:27:02 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-08-29T07:27:02Z</dc:date>
    <item>
      <title>Select Query not workin as expected</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-query-not-workin-as-expected/m-p/2718048#M630488</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HI Guru's, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is a select query which takes more time when I incerase the search criteria . The Table I_MKPF is not initial. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select mblnr mjahr zeile bwart matnr werks charg lifnr &lt;/P&gt;&lt;P&gt;shkzg bwtar menge meins ebeln aufnr bukrs prctr &lt;/P&gt;&lt;P&gt;from mseg into corresponding fields of table z_rec &lt;/P&gt;&lt;P&gt;for all entries in i_mkpf &lt;/P&gt;&lt;P&gt;where &lt;/P&gt;&lt;P&gt;mblnr eq i_mkpf-mblnr and &lt;/P&gt;&lt;P&gt;mjahr eq i_mkpf-mjahr and &lt;/P&gt;&lt;P&gt;bwart in s_bwart and &lt;/P&gt;&lt;P&gt;werks in s_werks and &lt;/P&gt;&lt;P&gt;bukrs in s_bukrs. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the above query MBLNR and MJAHR are primary key fields in the same order as in the database. &lt;/P&gt;&lt;P&gt;The query fetches 2 records and takes around 20 minutes. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I did some more testing and found one peculiar issue. &lt;/P&gt;&lt;P&gt;The query takes long time only when S_WERKS and/or S_BUKRS is entered on the selection screen. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If these two fields are left blank it works super quick. &lt;/P&gt;&lt;P&gt;I am baffled as to why this is happening. Should it not have been the other way around..? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could please take a look and tell me what the issue might be?? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in Advance, &lt;/P&gt;&lt;P&gt;Imran&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Aug 2007 07:21:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-query-not-workin-as-expected/m-p/2718048#M630488</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-08-29T07:21:00Z</dc:date>
    </item>
    <item>
      <title>Re: Select Query not workin as expected</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-query-not-workin-as-expected/m-p/2718049#M630489</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;Instead of going for into corresponding fields of table z_rec ,go for into table z_rec by declarng all the fields in the sequence which u selct from database.&lt;/P&gt;&lt;P&gt;2&amp;gt;in the where condition specify the fields inorder how they appaers in SE11 fro table MSEG&lt;/P&gt;&lt;P&gt;3&amp;gt;check for the initiality of the internal table I_MKPF before the select query.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Nagaraj&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Aug 2007 07:26:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-query-not-workin-as-expected/m-p/2718049#M630489</guid>
      <dc:creator>former_member404244</dc:creator>
      <dc:date>2007-08-29T07:26:07Z</dc:date>
    </item>
    <item>
      <title>Re: Select Query not workin as expected</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-query-not-workin-as-expected/m-p/2718050#M630490</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Imran,&lt;/P&gt;&lt;P&gt;please check the SQL performance in transaction ST05 &amp;gt; "Explaine one SQL request" for this slightly modified statement:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
select mblnr, mjahr, zeile, bwart, matnr, werks, charg, lifnr, 
shkzg, bwtar, menge, meins, ebeln, aufnr bukrs, prctr 
from mseg
where 
(
mblnr = '1' and 
mjahr = '2' and 
bwart in ('1', '2') and 
werks in ('1', '2') and 
bukrs in ('1', '2')
)
or
(
mblnr = '1' and 
mjahr = '2' and 
bwart in ('1', '2') and 
werks in ('1', '2') and 
bukrs in ('1', '2')
)
or
(
mblnr = '1' and 
mjahr = '2' and 
bwart in ('1', '2') and 
werks in ('1', '2') and 
bukrs in ('1', '2')
)
or
(
mblnr = '1' and 
mjahr = '2' and 
bwart in ('1', '2') and 
werks in ('1', '2') and 
bukrs in ('1', '2')
)
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please answer back with the results. Best regards,&lt;/P&gt;&lt;P&gt;Alvaro&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Aug 2007 07:27:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-query-not-workin-as-expected/m-p/2718050#M630490</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-08-29T07:27:02Z</dc:date>
    </item>
    <item>
      <title>Re: Select Query not workin as expected</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-query-not-workin-as-expected/m-p/2718051#M630491</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The table I_MKPF is not intial.&lt;/P&gt;&lt;P&gt;   The where condition is using the fields in the order used in SE11 in MSEG.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your help , but the problem seems to be something different.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Aug 2007 07:31:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-query-not-workin-as-expected/m-p/2718051#M630491</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-08-29T07:31:20Z</dc:date>
    </item>
    <item>
      <title>Re: Select Query not workin as expected</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-query-not-workin-as-expected/m-p/2718052#M630492</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HI,&lt;/P&gt;&lt;P&gt;First select the data based on the fields MBLNR and MJAHR.After fethching the data into the internal table then delete the entries ,which will not match the BUKRS and WERKS.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DO this deletion only select option have the data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think this will solves the problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;CSR.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;****Please Reward if helpful.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Aug 2007 07:43:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-query-not-workin-as-expected/m-p/2718052#M630492</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-08-29T07:43:53Z</dc:date>
    </item>
  </channel>
</rss>

