<?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: Experts modify this code in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/experts-modify-this-code/m-p/2615331#M600282</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;best way use only one query as :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;select a~mblnr a~mjahr b~matnr b~bwart b~menge
from mkpf as a inner join mseg as b
into table itab_mseg
on a~mblnr = b~mblnr and a~mjahr = b~mjahr
where a~budat in s_budat and
(a~vgart = 'WE' or a~vgart = 'WO') and
and b~werks = p_werks
and b~bwart in ('501', '502').&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;this is most optimised format i think ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;in for all entries u can not give criteria on internal table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Jogdand M B&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*Reward pts if helpful&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: &lt;/P&gt;&lt;P&gt;        Jogdand M B&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 31 Jul 2007 07:22:16 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-07-31T07:22:16Z</dc:date>
    <item>
      <title>Experts modify this code</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/experts-modify-this-code/m-p/2615327#M600278</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Experts please solve this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select mblnr into table itab1&lt;/P&gt;&lt;P&gt;from mkpf&lt;/P&gt;&lt;P&gt;where budat in s_budat&lt;/P&gt;&lt;P&gt;and vgart = 'WE'.&lt;/P&gt;&lt;P&gt;select mblnr into table itab2&lt;/P&gt;&lt;P&gt;from mkpf&lt;/P&gt;&lt;P&gt;where budat in s_budat&lt;/P&gt;&lt;P&gt;and vgart = 'WO'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I modified the above query as &lt;/P&gt;&lt;P&gt;select mblnr into table itab1&lt;/P&gt;&lt;P&gt;from mkpf&lt;/P&gt;&lt;P&gt;where budat in s_budat&lt;/P&gt;&lt;P&gt;and ( vgart = 'WE'or vgart = 'WO').&lt;/P&gt;&lt;P&gt;Now please tell me how to modify the below query because we have to select data only from itab1 entrieswhere vgart= we only.But in above we selected vgart = 'wo' into itab1.&lt;/P&gt;&lt;P&gt;select mblnr matnr bwart menge into table lt_menge&lt;/P&gt;&lt;P&gt;from mseg&lt;/P&gt;&lt;P&gt;for all entries in itab1.&lt;/P&gt;&lt;P&gt;where mblnr = lt_we-mblnr&lt;/P&gt;&lt;P&gt;and matnr = it_temp-matnr&lt;/P&gt;&lt;P&gt;and werks = p_werks&lt;/P&gt;&lt;P&gt;and bwart in ('501', '502').&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 31 Jul 2007 06:56:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/experts-modify-this-code/m-p/2615327#M600278</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-07-31T06:56:04Z</dc:date>
    </item>
    <item>
      <title>Re: Experts modify this code</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/experts-modify-this-code/m-p/2615328#M600279</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Shiva,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You need to create another internal table with the same type of itab1 and move the data corresponding to WE and use that for querying MSEG.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Atish&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 31 Jul 2007 07:03:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/experts-modify-this-code/m-p/2615328#M600279</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-07-31T07:03:15Z</dc:date>
    </item>
    <item>
      <title>Re: Experts modify this code</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/experts-modify-this-code/m-p/2615329#M600280</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;loop at itab1 where vgart = 'WE'.&lt;/P&gt;&lt;P&gt;move itab1 to itab2.&lt;/P&gt;&lt;P&gt;append itab2.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;now use itab2 in the for all entries.&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>Tue, 31 Jul 2007 07:08:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/experts-modify-this-code/m-p/2615329#M600280</guid>
      <dc:creator>gopi_narendra</dc:creator>
      <dc:date>2007-07-31T07:08:07Z</dc:date>
    </item>
    <item>
      <title>Re: Experts modify this code</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/experts-modify-this-code/m-p/2615330#M600281</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;select mblnr into table itab1 from mkpf where budat in s_budat  &lt;/P&gt;&lt;P&gt;                                                                      and vgart = 'WE'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select mblnr into table itab2 from mkpf where budat in s_budat&lt;/P&gt;&lt;P&gt;                                                                    and vgart = 'WO'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I modified the above query as &lt;/P&gt;&lt;P&gt;select mblnr into table itab1 from mkpf&lt;/P&gt;&lt;P&gt;                                                     where budat in s_budat&lt;/P&gt;&lt;P&gt;                                                     and vgart in ('WE' , 'WO').&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now please tell me how to modify the below query because we have to select data only from itab1 entrieswhere vgart= we only.But in above we selected vgart = 'wo' into itab1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;decleare another internal table move it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;itab3&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;itab3 = itab2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select mblnr matnr bwart menge into table lt_menge&lt;/P&gt;&lt;P&gt;from mseg  for all entries in itab1.&lt;/P&gt;&lt;P&gt;                           where mblnr = lt_we-mblnr&lt;/P&gt;&lt;P&gt;                             and matnr = it_temp-matnr&lt;/P&gt;&lt;P&gt;                             and werks = p_werks&lt;/P&gt;&lt;P&gt;                            and bwart in ('501', '502').&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 31 Jul 2007 07:14:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/experts-modify-this-code/m-p/2615330#M600281</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-07-31T07:14:04Z</dc:date>
    </item>
    <item>
      <title>Re: Experts modify this code</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/experts-modify-this-code/m-p/2615331#M600282</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;best way use only one query as :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;select a~mblnr a~mjahr b~matnr b~bwart b~menge
from mkpf as a inner join mseg as b
into table itab_mseg
on a~mblnr = b~mblnr and a~mjahr = b~mjahr
where a~budat in s_budat and
(a~vgart = 'WE' or a~vgart = 'WO') and
and b~werks = p_werks
and b~bwart in ('501', '502').&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;this is most optimised format i think ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;in for all entries u can not give criteria on internal table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Jogdand M B&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*Reward pts if helpful&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: &lt;/P&gt;&lt;P&gt;        Jogdand M B&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 31 Jul 2007 07:22:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/experts-modify-this-code/m-p/2615331#M600282</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-07-31T07:22:16Z</dc:date>
    </item>
    <item>
      <title>Re: Experts modify this code</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/experts-modify-this-code/m-p/2615332#M600283</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Shiva,&lt;/P&gt;&lt;P&gt;This is very simple&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt; Hello Experts please solve this&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;Don't use this. Select both of them in the same table as you did but with some correction.&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;gt; select mblnr into table itab1&lt;/P&gt;&lt;P&gt;&amp;gt; from mkpf&lt;/P&gt;&lt;P&gt;&amp;gt; where budat in s_budat&lt;/P&gt;&lt;P&gt;&amp;gt; and vgart = 'WE'.&lt;/P&gt;&lt;P&gt;&amp;gt; select mblnr into table itab2&lt;/P&gt;&lt;P&gt;&amp;gt; from mkpf&lt;/P&gt;&lt;P&gt;&amp;gt; where budat in s_budat&lt;/P&gt;&lt;P&gt;&amp;gt; and vgart = 'WO'.&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; I modified the above query as &lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;select mblnr VGART into table itab1
 from mkpf
 where budat in s_budat
   and VGART in ( 'WE' , 'WO' )&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;lt;b&amp;gt; modified the line&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;gt; and ( vgart = 'WE'or vgart = 'WO').&lt;/P&gt;&lt;P&gt;&amp;gt; Now please tell me how to modify the below query&lt;/P&gt;&lt;P&gt;&amp;gt; because we have to select data only from itab1&lt;/P&gt;&lt;P&gt;&amp;gt; entrieswhere vgart= we only.But in above we selected&lt;/P&gt;&lt;P&gt;&amp;gt; vgart = 'wo' into itab1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For this what you can do is simpler now.&lt;/P&gt;&lt;P&gt;Create another table itab2 with field MBLNR and VGART.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Write &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;   
   Loop at itab1 where VGART =  'WE'.
     MOVE itab2 = itab1.
     APPEND itab2.
   Endloop.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt; select mblnr matnr bwart menge into table lt_menge&lt;/P&gt;&lt;P&gt;&amp;gt; from mseg&lt;/P&gt;&lt;P&gt;&amp;gt; for all entries in itab1.&lt;/P&gt;&lt;P&gt;&amp;gt; where mblnr = lt_we-mblnr&lt;/P&gt;&lt;P&gt;&amp;gt; and matnr = it_temp-matnr&lt;/P&gt;&lt;P&gt;&amp;gt; and werks = p_werks&lt;/P&gt;&lt;P&gt;&amp;gt; and bwart in ('501', '502').&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now you can re-write this as :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
 select mblnr matnr bwart menge into table lt_menge
 from mseg
 for all entries in ITAB2
 where mblnr = ITAB2-mblnr
 and matnr = it_temp-matnr
 and werks = p_werks
 and bwart in ('501', '502').
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;lt;b&amp;gt;hope the above solves your issue&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Nishant&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 31 Jul 2007 07:43:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/experts-modify-this-code/m-p/2615332#M600283</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-07-31T07:43:29Z</dc:date>
    </item>
  </channel>
</rss>

