<?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 in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/query/m-p/2760112#M642537</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Few things to be taken care&lt;/P&gt;&lt;P&gt;1. The order of fields in your query are not according to the standard table fields order&lt;/P&gt;&lt;P&gt;2. Avoid using into corresponding fields.&lt;/P&gt;&lt;P&gt;3. Sort itab by mblnr.&lt;/P&gt;&lt;P&gt;4. Use if not itab[] is initial. before starting the query.&lt;/P&gt;&lt;P&gt;5. First use MKPF and then join on MSEG ( you did the reverse of it) since MKPF is header and MSEG is the item table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And why are you querying 2 times on the same tables instead you can do it in one shot.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Gopi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 05 Sep 2007 09:17:01 GMT</pubDate>
    <dc:creator>gopi_narendra</dc:creator>
    <dc:date>2007-09-05T09:17:01Z</dc:date>
    <item>
      <title>query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/query/m-p/2760110#M642535</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi experts&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i have the following query, it contains faulty data, it returns all kdaufs which is not match with itab-kdauf, can u tell me whats the error in this query. can we check bwart field as follows.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select   a~mblnr&lt;/P&gt;&lt;P&gt;         a~kdauf&lt;/P&gt;&lt;P&gt;         a~kdpos&lt;/P&gt;&lt;P&gt;         a~matnr&lt;/P&gt;&lt;P&gt;         a~werks&lt;/P&gt;&lt;P&gt;         a~erfmg&lt;/P&gt;&lt;P&gt;         a~erfme&lt;/P&gt;&lt;P&gt;         a~BWART&lt;/P&gt;&lt;P&gt;         b~budat&lt;/P&gt;&lt;P&gt;         from mseg as a&lt;/P&gt;&lt;P&gt;         inner join mkpf as b on&lt;/P&gt;&lt;P&gt;         a&lt;SUB&gt;mblnr = b&lt;/SUB&gt;mblnr&lt;/P&gt;&lt;P&gt;         into corresponding fields of table  itab1&lt;/P&gt;&lt;P&gt;         for all entries in itab&lt;/P&gt;&lt;P&gt;         where a~kdauf = itab-kdauf&lt;/P&gt;&lt;P&gt;           and a~kdpos = itab-kdpos and&lt;/P&gt;&lt;P&gt;           a&lt;SUB&gt;bwart = '601' or a&lt;/SUB&gt;bwart = '602' and&lt;/P&gt;&lt;P&gt;           a~WERKS = itab-werks and&lt;/P&gt;&lt;P&gt;           b~budat le itab-budat.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="3" type="ul"&gt;&lt;P&gt;itab  as follows**&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT mseg~mblnr&lt;/P&gt;&lt;P&gt;         mkpf~budat&lt;/P&gt;&lt;P&gt;         mseg~kdauf&lt;/P&gt;&lt;P&gt;         mseg~kdpos&lt;/P&gt;&lt;P&gt;         mseg~matnr&lt;/P&gt;&lt;P&gt;         mseg~werks&lt;/P&gt;&lt;P&gt;         mseg~erfmg&lt;/P&gt;&lt;P&gt;         mseg~erfme&lt;/P&gt;&lt;P&gt;         mseg~BWART&lt;/P&gt;&lt;P&gt;         from mseg&lt;/P&gt;&lt;P&gt;         inner join&lt;/P&gt;&lt;P&gt;         mkpf on mkpf&lt;SUB&gt;mblnr EQ mseg&lt;/SUB&gt;mblnr&lt;/P&gt;&lt;P&gt;                 into table itab&lt;/P&gt;&lt;P&gt;         where mkpf~budat in zdate and&lt;/P&gt;&lt;P&gt;            mseg~werks in zpl and&lt;/P&gt;&lt;P&gt;            ( mseg~BWART = '601' or&lt;/P&gt;&lt;P&gt;            mseg~bwart = '602').&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;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Rajaram&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Sep 2007 09:14:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/query/m-p/2760110#M642535</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-09-05T09:14:30Z</dc:date>
    </item>
    <item>
      <title>Re: query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/query/m-p/2760111#M642536</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;first chk db tables matches data found.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;after chk length of two fields example numeric or number type.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Sep 2007 09:16:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/query/m-p/2760111#M642536</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-09-05T09:16:52Z</dc:date>
    </item>
    <item>
      <title>Re: query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/query/m-p/2760112#M642537</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Few things to be taken care&lt;/P&gt;&lt;P&gt;1. The order of fields in your query are not according to the standard table fields order&lt;/P&gt;&lt;P&gt;2. Avoid using into corresponding fields.&lt;/P&gt;&lt;P&gt;3. Sort itab by mblnr.&lt;/P&gt;&lt;P&gt;4. Use if not itab[] is initial. before starting the query.&lt;/P&gt;&lt;P&gt;5. First use MKPF and then join on MSEG ( you did the reverse of it) since MKPF is header and MSEG is the item table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And why are you querying 2 times on the same tables instead you can do it in one shot.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Gopi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Sep 2007 09:17:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/query/m-p/2760112#M642537</guid>
      <dc:creator>gopi_narendra</dc:creator>
      <dc:date>2007-09-05T09:17:01Z</dc:date>
    </item>
    <item>
      <title>Re: query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/query/m-p/2760113#M642538</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;First write&lt;/P&gt;&lt;P&gt;SELECT mseg~mblnr&lt;/P&gt;&lt;P&gt;mseg~matnr&lt;/P&gt;&lt;P&gt;mseg~werks&lt;/P&gt;&lt;P&gt;mseg~kdauf&lt;/P&gt;&lt;P&gt;mseg~kdpos&lt;/P&gt;&lt;P&gt;mseg~erfmg&lt;/P&gt;&lt;P&gt;mseg~erfme&lt;/P&gt;&lt;P&gt;mseg~BWART&lt;/P&gt;&lt;P&gt;mkpf~budat&lt;/P&gt;&lt;P&gt;from mseg&lt;/P&gt;&lt;P&gt;inner join&lt;/P&gt;&lt;P&gt;mkpf on mseg&lt;SUB&gt;mblnr EQ mkpf&lt;/SUB&gt;mblnr&lt;/P&gt;&lt;P&gt;into table itab&lt;/P&gt;&lt;P&gt;where mkpf~budat in zdate and&lt;/P&gt;&lt;P&gt;mseg~werks in zpl and&lt;/P&gt;&lt;P&gt;( mseg~BWART = '601' or&lt;/P&gt;&lt;P&gt;mseg~bwart = '602').&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;If itab[] is not intial.&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select a~mblnr&lt;/P&gt;&lt;P&gt;a~BWART&lt;/P&gt;&lt;P&gt;a~matnr&lt;/P&gt;&lt;P&gt;a~werks&lt;/P&gt;&lt;P&gt;a~kdauf&lt;/P&gt;&lt;P&gt;a~kdpos&lt;/P&gt;&lt;P&gt;a~erfmg&lt;/P&gt;&lt;P&gt;a~erfme&lt;/P&gt;&lt;P&gt;b~budat&lt;/P&gt;&lt;P&gt;from mseg as a&lt;/P&gt;&lt;P&gt;inner join mkpf as b on&lt;/P&gt;&lt;P&gt;a&lt;SUB&gt;mblnr = b&lt;/SUB&gt;mblnr&lt;/P&gt;&lt;P&gt;into table itab1  "define ITAb1 with the fields selected &lt;/P&gt;&lt;P&gt;                  "above in the same order&lt;/P&gt;&lt;P&gt;for all entries in itab&lt;/P&gt;&lt;P&gt;where a~kdauf = itab-kdauf&lt;/P&gt;&lt;P&gt;and a~kdpos = itab-kdpos and&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;( a&lt;SUB&gt;bwart = '601' or a&lt;/SUB&gt;bwart = '602')&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;and a~WERKS = itab-werks &lt;/P&gt;&lt;P&gt;and b~budat le itab-budat.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&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;All the fields are selected in order..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You need to check if ITAB is not initial.. If ITAb is initial you will get all the values from the table..&lt;/P&gt;&lt;P&gt;rewards if useful,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;nazeer&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Sep 2007 09:18:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/query/m-p/2760113#M642538</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-09-05T09:18:25Z</dc:date>
    </item>
    <item>
      <title>Re: query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/query/m-p/2760114#M642539</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi Raja,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you have to change the WHERE part like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;where a~kdauf = itab-kdauf&lt;/P&gt;&lt;P&gt;and a~kdpos = itab-kdpos and&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;(&amp;lt;/b&amp;gt; a&lt;SUB&gt;bwart = '601' or a&lt;/SUB&gt;bwart = '602' &amp;lt;b&amp;gt;)&amp;lt;/b&amp;gt; and&lt;/P&gt;&lt;P&gt;a~WERKS = itab-werks and&lt;/P&gt;&lt;P&gt;b~budat le itab-budat.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ec&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Sep 2007 09:18:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/query/m-p/2760114#M642539</guid>
      <dc:creator>JozsefSzikszai</dc:creator>
      <dc:date>2007-09-05T09:18:48Z</dc:date>
    </item>
  </channel>
</rss>

