<?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: Query producing Wrong Output in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/query-producing-wrong-output/m-p/12612252#M2011896</link>
    <description>&lt;P&gt;Thanks Sandra I understand the fact.&lt;/P&gt;</description>
    <pubDate>Mon, 06 Jun 2022 04:23:13 GMT</pubDate>
    <dc:creator>shahad009</dc:creator>
    <dc:date>2022-06-06T04:23:13Z</dc:date>
    <item>
      <title>Query producing Wrong Output</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/query-producing-wrong-output/m-p/12612249#M2011893</link>
      <description>&lt;P&gt;Hi experts,&lt;/P&gt;
  &lt;P&gt;I have written a query but its not producing right output... to be more precise quantity field condition is not checked.&lt;/P&gt;
  &lt;P&gt; SELECT&lt;/P&gt; a~werks,
  &lt;BR /&gt; a~lgort,
  &lt;BR /&gt; a~matnr,
  &lt;BR /&gt; a~charg,
  &lt;BR /&gt; a~ersda,
  &lt;BR /&gt; a~clabs,
  &lt;BR /&gt; a~cinsm,
  &lt;BR /&gt; a~cspem,
  &lt;BR /&gt; b~maktx,
  &lt;BR /&gt; c~meins,
  &lt;BR /&gt; concat( a~matnr, a~charg ) AS merge
  &lt;BR /&gt; FROM mchb AS a
  &lt;BR /&gt; INNER JOIN makt AS b
  &lt;BR /&gt; ON a~matnr = b~matnr
  &lt;BR /&gt; INNER JOIN mara AS c
  &lt;BR /&gt; ON a~matnr = c~matnr
  &lt;BR /&gt; WHERE a~lgort = @p_store OR
  &lt;BR /&gt; a~werks = @p_plant AND
  &lt;BR /&gt; a~matnr IN @s_matnr AND
  &lt;BR /&gt; a~charg IN @s_batch AND
  &lt;BR /&gt; ( a~clabs &amp;gt; 0 OR a~cinsm &amp;gt; 0 OR a~cspem &amp;gt; 0 )
  &lt;BR /&gt; INTO TABLE @DATA(it_mchb).
  &lt;BR /&gt;
  &lt;P&gt;My selection screen looks like&lt;/P&gt;SELECTION-SCREEN BEGIN OF BLOCK b WITH FRAME TITLE txt-001.
  &lt;BR /&gt;
  &lt;BR /&gt;
  &lt;BR /&gt;PARAMETERS : p_plant TYPE t001w-werks MATCHCODE OBJECT zpl ,
  &lt;BR /&gt; p_store TYPE mchb-lgort OBLIGATORY MATCHCODE OBJECT zsl.
  &lt;BR /&gt;
  &lt;BR /&gt;
  &lt;BR /&gt;SELECT-OPTIONS : s_matnr FOR mara-matnr ,
  &lt;BR /&gt; s_batch FOR mska-charg MATCHCODE OBJECT zbt.
  &lt;BR /&gt;
  &lt;BR /&gt;
  &lt;BR /&gt;PARAMETERS : r1 AS CHECKBOX.
  &lt;BR /&gt;
  &lt;BR /&gt;
  &lt;BR /&gt;
  &lt;P&gt;SELECTION-SCREEN END OF BLOCK b.&lt;/P&gt;</description>
      <pubDate>Sun, 05 Jun 2022 10:27:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/query-producing-wrong-output/m-p/12612249#M2011893</guid>
      <dc:creator>shahad009</dc:creator>
      <dc:date>2022-06-05T10:27:46Z</dc:date>
    </item>
    <item>
      <title>Re: Query producing Wrong Output</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/query-producing-wrong-output/m-p/12612250#M2011894</link>
      <description>&lt;P&gt;I already told you in your previous question that it's wrong due to the AND/OR priority, but your query anyway is wrong. Parentheses:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;WHERE ( a~lgort = @p_store OR
        a~werks = @p_plant )
   AND ...&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;But it's wrong, because if the table MCHB is like this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;        LGORT  WERKS
Line 1  abc    123
Line 2  abc    456
Line 3  def    123&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;it won't work in case 1:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;         P_STORE  P_PLANT  Expected result  Actual result      Status
Case 1   abc      123      Line 1           Lines 1, 2 and 3   KO
Case 2   abc               Lines 1 and 2    Lines 1 and 2      OK&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 05 Jun 2022 10:33:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/query-producing-wrong-output/m-p/12612250#M2011894</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2022-06-05T10:33:12Z</dc:date>
    </item>
    <item>
      <title>Re: Query producing Wrong Output</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/query-producing-wrong-output/m-p/12612251#M2011895</link>
      <description>&lt;P&gt;Hi &lt;/P&gt;&lt;P&gt;As Sandra said,&lt;/P&gt;&lt;P&gt;You need to clarify in following Points&lt;/P&gt;&lt;P&gt;1. The Storage location name - (say ABC ) - is exist in all Plants and if you give only storage location as input then&lt;/P&gt;&lt;P&gt;   - the results will contain materials with quantity from that storage locations from all the plants&lt;/P&gt;&lt;P&gt;2. If you give Input Plant only - then &lt;/P&gt;&lt;P&gt;   - the results will contain materials with quantity from all storage locations of that plant&lt;/P&gt;&lt;P&gt;3. If you give input both plant and storage location&lt;/P&gt;&lt;P&gt;   - then the result will be correct as it is very specific&lt;/P&gt;&lt;P&gt;So If you say case 1 and 2 are okay to you then modify the SQL where clause with OR operation inside paranthesis&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;WHERE ( a~lgort = @p_store OR
        a~werks = @p_plant )&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Or If you say case 1 and 2 are not okay then make both plant and stoage loacation as mandatory and put AND operator in SQL query  (paramethesis is not required)&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;WHERE   a~lgort = @p_store AND
        a~werks = @p_plant &lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Kindly update with your clarification with business and/or Functional consultant&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Venkat&lt;/P&gt;</description>
      <pubDate>Sun, 05 Jun 2022 12:35:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/query-producing-wrong-output/m-p/12612251#M2011895</guid>
      <dc:creator>venkateswaran_k</dc:creator>
      <dc:date>2022-06-05T12:35:02Z</dc:date>
    </item>
    <item>
      <title>Re: Query producing Wrong Output</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/query-producing-wrong-output/m-p/12612252#M2011896</link>
      <description>&lt;P&gt;Thanks Sandra I understand the fact.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Jun 2022 04:23:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/query-producing-wrong-output/m-p/12612252#M2011896</guid>
      <dc:creator>shahad009</dc:creator>
      <dc:date>2022-06-06T04:23:13Z</dc:date>
    </item>
    <item>
      <title>Re: Query producing Wrong Output</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/query-producing-wrong-output/m-p/12612253#M2011897</link>
      <description>&lt;P&gt;hi &lt;SPAN class="mention-scrubbed"&gt;venkateswaran.k&lt;/SPAN&gt;,&lt;/P&gt;&lt;P&gt;Case 1 and 3 will be ok. not 2 as plant is not a mandatory field. But ur proposed technique is producing wrong output too.&lt;/P&gt;&lt;P&gt;when I am giving both plant and storage location as input. Its not filtering the storage location. here is the query.&lt;/P&gt;&lt;P&gt;The report has only one mandatory field that is storage location so only if user gives storage location the report should run.&lt;/P&gt;&lt;P&gt;if applies plant material batch the data will be filtered else wil not.&lt;/P&gt;&lt;P&gt; SELECT&lt;BR /&gt;   a~werks,&lt;BR /&gt;   a~lgort,&lt;BR /&gt;   a~matnr,&lt;BR /&gt;   a~charg,&lt;BR /&gt;   a~ersda,&lt;BR /&gt;   a~clabs,&lt;BR /&gt;   a~cinsm,&lt;BR /&gt;   a~cspem,&lt;BR /&gt;   b~maktx,&lt;BR /&gt;   c~meins,&lt;BR /&gt;   concat( a~matnr, a~charg ) AS merge&lt;BR /&gt;   FROM mchb AS a&lt;BR /&gt;   INNER JOIN makt AS b&lt;BR /&gt;   ON a~matnr = b~matnr&lt;BR /&gt;   INNER JOIN mara AS c&lt;BR /&gt;   ON a~matnr = c~matnr&lt;BR /&gt;   WHERE ( a~lgort = @p_store OR a~werks = @p_plant ) AND&lt;BR /&gt;   a~matnr IN @s_matnr AND&lt;BR /&gt;   a~charg IN @s_batch AND&lt;BR /&gt;   ( a~clabs &amp;gt; 0 OR a~cinsm &amp;gt; 0 OR a~cspem &amp;gt; 0 )&lt;BR /&gt;   INTO TABLE @DATA(it_mchb).&lt;/P&gt;</description>
      <pubDate>Mon, 06 Jun 2022 05:46:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/query-producing-wrong-output/m-p/12612253#M2011897</guid>
      <dc:creator>shahad009</dc:creator>
      <dc:date>2022-06-06T05:46:59Z</dc:date>
    </item>
    <item>
      <title>Re: Query producing Wrong Output</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/query-producing-wrong-output/m-p/12612254#M2011898</link>
      <description>&lt;P&gt;hmm okay.  If the user requirement is that, then okay. I just mention this you to clarify with business with possible cases.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Jun 2022 05:53:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/query-producing-wrong-output/m-p/12612254#M2011898</guid>
      <dc:creator>venkateswaran_k</dc:creator>
      <dc:date>2022-06-06T05:53:35Z</dc:date>
    </item>
    <item>
      <title>Re: Query producing Wrong Output</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/query-producing-wrong-output/m-p/12612255#M2011899</link>
      <description>&lt;P&gt;so can i achieve it using a single query?&lt;/P&gt;&lt;P&gt;or i have to write two quries. for example if p_plant is initial the  OR&lt;/P&gt;&lt;P&gt;or P_plant is not initial then AND .&lt;/P&gt;</description>
      <pubDate>Mon, 06 Jun 2022 06:02:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/query-producing-wrong-output/m-p/12612255#M2011899</guid>
      <dc:creator>shahad009</dc:creator>
      <dc:date>2022-06-06T06:02:38Z</dc:date>
    </item>
    <item>
      <title>Re: Query producing Wrong Output</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/query-producing-wrong-output/m-p/12612256#M2011900</link>
      <description>&lt;P&gt;Yes, the query you now pasted (single query with OR operator within paranthesis)  should work for you.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Jun 2022 06:05:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/query-producing-wrong-output/m-p/12612256#M2011900</guid>
      <dc:creator>venkateswaran_k</dc:creator>
      <dc:date>2022-06-06T06:05:56Z</dc:date>
    </item>
    <item>
      <title>Re: Query producing Wrong Output</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/query-producing-wrong-output/m-p/12612257#M2011901</link>
      <description>&lt;P&gt;but its not working when i am giving both plant and storage location. its pulling data of all storage location.&lt;/P&gt;&lt;P&gt;the reason being its an or operator between p_plant and p_store.&lt;/P&gt;&lt;P&gt;so i am thinking that i will use an if condition if p_plant is initial the  p_store or p_plant&lt;/P&gt;&lt;P&gt;                                                                       if p_plant is not initial p_store and p_plant.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Jun 2022 06:08:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/query-producing-wrong-output/m-p/12612257#M2011901</guid>
      <dc:creator>shahad009</dc:creator>
      <dc:date>2022-06-06T06:08:20Z</dc:date>
    </item>
    <item>
      <title>Re: Query producing Wrong Output</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/query-producing-wrong-output/m-p/12612258#M2011902</link>
      <description>&lt;P&gt;hi venkat,&lt;/P&gt;&lt;P&gt;I did this. Is it ok now?&lt;/P&gt;&lt;P&gt; IF p_plant IS INITIAL.
&lt;BR /&gt;
&lt;BR /&gt; SELECT
&lt;BR /&gt; a~werks,
&lt;BR /&gt; a~lgort,
&lt;BR /&gt; a~matnr,
&lt;BR /&gt; a~charg,
&lt;BR /&gt; a~ersda,
&lt;BR /&gt; a~clabs,
&lt;BR /&gt; a~cinsm,
&lt;BR /&gt; a~cspem,
&lt;BR /&gt; b~maktx,
&lt;BR /&gt; c~meins,
&lt;BR /&gt; concat( a~matnr, a~charg ) AS merge
&lt;BR /&gt; FROM mchb AS a
&lt;BR /&gt; INNER JOIN makt AS b
&lt;BR /&gt; ON a~matnr = b~matnr
&lt;BR /&gt; INNER JOIN mara AS c
&lt;BR /&gt; ON a~matnr = c~matnr
&lt;BR /&gt; WHERE ( a~lgort = @p_store OR a~werks = @p_plant ) AND
&lt;BR /&gt; a~matnr IN @s_matnr AND
&lt;BR /&gt; a~charg IN @s_batch AND
&lt;BR /&gt; ( a~clabs &amp;gt; 0 OR a~cinsm &amp;gt; 0 OR a~cspem &amp;gt; 0 )
&lt;BR /&gt; INTO TABLE @DATA(it_mchb).
&lt;BR /&gt;
&lt;BR /&gt; ELSE.
&lt;BR /&gt; SELECT
&lt;BR /&gt;a~werks,
&lt;BR /&gt;a~lgort,
&lt;BR /&gt;a~matnr,
&lt;BR /&gt;a~charg,
&lt;BR /&gt;a~ersda,
&lt;BR /&gt;a~clabs,
&lt;BR /&gt;a~cinsm,
&lt;BR /&gt;a~cspem,
&lt;BR /&gt;b~maktx,
&lt;BR /&gt;c~meins,
&lt;BR /&gt;concat( a~matnr, a~charg ) AS merge
&lt;BR /&gt;FROM mchb AS a
&lt;BR /&gt;INNER JOIN makt AS b
&lt;BR /&gt;ON a~matnr = b~matnr
&lt;BR /&gt;INNER JOIN mara AS c
&lt;BR /&gt;ON a~matnr = c~matnr
&lt;BR /&gt;WHERE a~lgort = @p_store AND a~werks = @p_plant AND
&lt;BR /&gt;a~matnr IN @s_matnr AND
&lt;BR /&gt;a~charg IN @s_batch AND
&lt;BR /&gt;( a~clabs &amp;gt; 0 OR a~cinsm &amp;gt; 0 OR a~cspem &amp;gt; 0 )
&lt;BR /&gt;INTO TABLE @DATA(it_mchb2).
&lt;BR /&gt;
&lt;BR /&gt;
&lt;/P&gt;&lt;P&gt; ENDIF.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Jun 2022 06:27:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/query-producing-wrong-output/m-p/12612258#M2011902</guid>
      <dc:creator>shahad009</dc:creator>
      <dc:date>2022-06-06T06:27:49Z</dc:date>
    </item>
    <item>
      <title>Re: Query producing Wrong Output</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/query-producing-wrong-output/m-p/12612259#M2011903</link>
      <description>&lt;P&gt;IF p_plant IS INITIAL.-  case  then you need not specify OR a~werks = @p_plant...  - you can remove that.&lt;/P&gt;&lt;P&gt;otherwise looks okay to me.. &lt;/P&gt;&lt;P&gt;However, still that single query will also work for you.. &lt;/P&gt;&lt;P&gt;It is upto you to choose either .. &lt;/P&gt;</description>
      <pubDate>Mon, 06 Jun 2022 06:32:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/query-producing-wrong-output/m-p/12612259#M2011903</guid>
      <dc:creator>venkateswaran_k</dc:creator>
      <dc:date>2022-06-06T06:32:23Z</dc:date>
    </item>
    <item>
      <title>Re: Query producing Wrong Output</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/query-producing-wrong-output/m-p/12612260#M2011904</link>
      <description>&lt;P&gt;but that single query is not working. as i said it producing wrong output when i am giving  both plant and storage in initilal screen.&lt;/P&gt;&lt;P&gt;My scenerio is only p_store is mandatory so only putting p_store the report should run. Also both giving p_plant and p_store report should run properly.&lt;/P&gt;&lt;P&gt;Hope u get my point.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Jun 2022 06:37:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/query-producing-wrong-output/m-p/12612260#M2011904</guid>
      <dc:creator>shahad009</dc:creator>
      <dc:date>2022-06-06T06:37:12Z</dc:date>
    </item>
    <item>
      <title>Re: Query producing Wrong Output</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/query-producing-wrong-output/m-p/12612261#M2011905</link>
      <description>&lt;P&gt;Oh okay,,  then this If condition based sql should work &lt;/P&gt;</description>
      <pubDate>Mon, 06 Jun 2022 06:39:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/query-producing-wrong-output/m-p/12612261#M2011905</guid>
      <dc:creator>venkateswaran_k</dc:creator>
      <dc:date>2022-06-06T06:39:36Z</dc:date>
    </item>
    <item>
      <title>Re: Query producing Wrong Output</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/query-producing-wrong-output/m-p/12612262#M2011906</link>
      <description>&lt;P&gt;Yes, but its more code .. i wanted it in an optimized way. &lt;/P&gt;</description>
      <pubDate>Mon, 06 Jun 2022 06:45:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/query-producing-wrong-output/m-p/12612262#M2011906</guid>
      <dc:creator>shahad009</dc:creator>
      <dc:date>2022-06-06T06:45:33Z</dc:date>
    </item>
    <item>
      <title>Re: Query producing Wrong Output</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/query-producing-wrong-output/m-p/12612263#M2011907</link>
      <description>&lt;P&gt;hmm okay. As per your requirement putting in if statement is the only option I believe.&lt;/P&gt;&lt;P&gt;However, can you give screenshot of example - when you say the output of single query is wrong.  Please give example - if we put in single query - what is the expected result and what is actually coming - so that we can narrow down where the issue is?&lt;/P&gt;</description>
      <pubDate>Mon, 06 Jun 2022 09:40:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/query-producing-wrong-output/m-p/12612263#M2011907</guid>
      <dc:creator>venkateswaran_k</dc:creator>
      <dc:date>2022-06-06T09:40:30Z</dc:date>
    </item>
    <item>
      <title>Re: Query producing Wrong Output</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/query-producing-wrong-output/m-p/12612264#M2011908</link>
      <description>&lt;P&gt;Hi &lt;SPAN class="mention-scrubbed"&gt;shahad009&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;If you want to optimize the code, then do as follows : Instead of Parameters, you change the Plant and Storage location to Select-option&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT-OPTIONS : 
s_lgort for mchb-lgort obligatory matchcode object zsl,
s_plant for t001w-werks matchcode object zpl&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;and change the query as follows (single query )&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT
a~werks,
a~lgort,
a~matnr,
a~charg,
a~ersda,
a~clabs,
a~cinsm,
a~cspem,
b~maktx,
c~meins,
concat( a~matnr, a~charg ) AS merge
FROM mchb AS a
INNER JOIN makt AS b
ON a~matnr = b~matnr
INNER JOIN mara AS c
ON a~matnr = c~matnr
WHERE 
a~lgort IN @s_store AND    &amp;lt;==== changed here
a~werks IN @s_plant AND    &amp;lt;==== changed here
a~matnr IN @s_matnr AND
a~charg IN @s_batch AND
( a~clabs &amp;gt; 0 OR a~cinsm &amp;gt; 0 OR a~cspem &amp;gt; 0 )
INTO TABLE @DATA(it_mchb).
&lt;/CODE&gt;&lt;/PRE&gt;Let me know your input.</description>
      <pubDate>Mon, 06 Jun 2022 18:18:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/query-producing-wrong-output/m-p/12612264#M2011908</guid>
      <dc:creator>venkateswaran_k</dc:creator>
      <dc:date>2022-06-06T18:18:15Z</dc:date>
    </item>
    <item>
      <title>Re: Query producing Wrong Output</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/query-producing-wrong-output/m-p/12612265#M2011909</link>
      <description>&lt;P&gt;Hi &lt;SPAN class="mention-scrubbed"&gt;venkateswaran.k&lt;/SPAN&gt;,&lt;/P&gt;&lt;P&gt;Here i am explaining you why the single query was not working.&lt;/P&gt;&lt;P&gt;Note : p_store in the only mandatory field in the report. so now when i used the single query its an or operation between p_store p_plant. Right?&lt;/P&gt;&lt;P&gt;So when the user is giving both plant and storage location to run the report it is actually pulling all the storage location  data 8100 7100.... as its( p_plnat or p_plant)   in the query but if the user is only giving p_store to run the report the output is ok .&lt;/P&gt;&lt;P&gt;Hope u understand.&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jun 2022 03:53:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/query-producing-wrong-output/m-p/12612265#M2011909</guid>
      <dc:creator>shahad009</dc:creator>
      <dc:date>2022-06-07T03:53:40Z</dc:date>
    </item>
    <item>
      <title>Re: Query producing Wrong Output</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/query-producing-wrong-output/m-p/12612266#M2011910</link>
      <description>&lt;P&gt;Yes, Got it. &lt;/P&gt;&lt;P&gt;In that case you have to put IF statement for the Query as you mentioned earlier.. If that works, you can close this thread.  Writing two queries based on If condition is okay .. We cannot optimize the code further.. &lt;/P&gt;&lt;P&gt;Regards,Venkat&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jun 2022 05:11:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/query-producing-wrong-output/m-p/12612266#M2011910</guid>
      <dc:creator>venkateswaran_k</dc:creator>
      <dc:date>2022-06-07T05:11:04Z</dc:date>
    </item>
  </channel>
</rss>

