<?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 statement problem in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-problem/m-p/5090038#M1181547</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;even if im joining VBRK and VBRP but the thing is that they will have the same o/p it will not solve the prob..&lt;/P&gt;&lt;P&gt;the prob is for every entry from VBRK and VBRP join it shows all the cust. from Masterit shld go into masters table only once and not for every record......&lt;/P&gt;&lt;P&gt;thanx.....&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 06 Feb 2009 09:00:26 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2009-02-06T09:00:26Z</dc:date>
    <item>
      <title>select statement problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-problem/m-p/5090028#M1181537</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    im doing the sales report in which i want all the customers from master doesnt matter even if there is sale against them ...but im taking the VBRK fst then taking data from master bcoz if im taking master as base then it goes to VBRK and it takes lot of execution time. like.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;select kunrg vbeln fkdat vbtyp vkorg vtweg into
  (itab-kunnr,itab-vbeln,itab-fkdat,itab-vbtyp,itab-vkorg,itab-vtweg)
from vbrk
  where kunrg in kunnr and fkdat in fkdat and fksto ne 'X' and
  fkart &amp;lt;&amp;gt; 'ZRO' and vkorg in vkorg and vtweg in vtweg and spart in
 spart.


   select matnr matkl fkimg brgew kzwi6 netwr into
   (itab-matnr,itab-matkl,itab-fkimg,itab-brgew,itab-kzwi6,
   itab-netwr)
   from vbrp
   where vbeln = itab-vbeln.


select name1 vkorg vtweg spart vwerk bzirk kdgrp vkbur into
 (itab-name1,itab-vkorg,itab-vtweg,itab-spart,itab-vwerk,
itab-bzirk,itab-kdgrp,itab-vkbur)
 from kna1vv
 where kunnr in kunnr and vkorg in vkorg and vtweg in vtweg
and spart in spart and kunnr = itab-kunnr.


  check sy-subrc = 0.


append itab.
clear itab.

endselect.
endselect.
endselect.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the problem here is that for each entry in VBRK it displays all cust. from master again and again every time .. i want to avoid this ..&lt;/P&gt;&lt;P&gt;so plzz help me out..&lt;/P&gt;&lt;P&gt;thanxxx....&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Feb 2009 08:30:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-problem/m-p/5090028#M1181537</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-06T08:30:49Z</dc:date>
    </item>
    <item>
      <title>Re: select statement problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-problem/m-p/5090029#M1181538</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Select within select is not recommendable,it is costly statement.&lt;/P&gt;&lt;P&gt;This is the reason why it is taking time.&lt;/P&gt;&lt;P&gt;Use for all entries for second internal table looping.&lt;/P&gt;&lt;P&gt;Use internal table instead of writing individual workareas in into clause.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Sreesudha Gullapalli on Feb 6, 2009 9:37 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Feb 2009 08:37:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-problem/m-p/5090029#M1181538</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-06T08:37:10Z</dc:date>
    </item>
    <item>
      <title>Re: select statement problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-problem/m-p/5090030#M1181539</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;You can use inner join query. You can use the code below as a guide.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  SELECT A&lt;SUB&gt;lifnr B&lt;/SUB&gt;werks A&lt;SUB&gt;ebeln B&lt;/SUB&gt;ebelp A&lt;SUB&gt;bukrs A&lt;/SUB&gt;zterm A~ekorg&lt;/P&gt;&lt;P&gt;         A&lt;SUB&gt;ekgrp A&lt;/SUB&gt;aedat A&lt;SUB&gt;waers A&lt;/SUB&gt;kdate A&lt;SUB&gt;inco1 A&lt;/SUB&gt;inco2 A~adrnr&lt;/P&gt;&lt;P&gt;         B&lt;SUB&gt;matnr B&lt;/SUB&gt;menge B&lt;SUB&gt;meins B&lt;/SUB&gt;netpr B&lt;SUB&gt;netwr C&lt;/SUB&gt;eindt B~mwskz&lt;/P&gt;&lt;P&gt;         B~txz01&lt;/P&gt;&lt;P&gt;         INTO TABLE tb_po&lt;/P&gt;&lt;P&gt;         FROM ekko as A INNER JOIN ekpo as B&lt;/P&gt;&lt;P&gt;         ON A&lt;SUB&gt;ebeln = B&lt;/SUB&gt;ebeln&lt;/P&gt;&lt;P&gt;         INNER JOIN eket as C&lt;/P&gt;&lt;P&gt;         ON ( B&lt;SUB&gt;ebeln = C&lt;/SUB&gt;ebeln AND B&lt;SUB&gt;ebelp = C&lt;/SUB&gt;ebelp )&lt;/P&gt;&lt;P&gt;         WHERE A~ebeln IN so_ebeln&lt;/P&gt;&lt;P&gt;           AND A~bukrs =  p_bukrs&lt;/P&gt;&lt;P&gt;           AND A~aedat IN so_aedat&lt;/P&gt;&lt;P&gt;           AND A~lifnr IN so_lifnr&lt;/P&gt;&lt;P&gt;           AND A~ekorg =  p_ekorg&lt;/P&gt;&lt;P&gt;           AND A~ekgrp =  p_ekgrp&lt;/P&gt;&lt;P&gt;           AND A~bsart =  p_bsart&lt;/P&gt;&lt;P&gt;           AND B~loekz NE 'L'&lt;/P&gt;&lt;P&gt;           AND ( A&lt;SUB&gt;frgke = 'Q'  or A&lt;/SUB&gt;frgke = ' '  ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mon Magallanes&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Feb 2009 08:37:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-problem/m-p/5090030#M1181539</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-06T08:37:12Z</dc:date>
    </item>
    <item>
      <title>Re: select statement problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-problem/m-p/5090031#M1181540</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt; Hi,&lt;/P&gt;&lt;P&gt;&amp;gt; Select within select is not recommendable,it is costly statement.&lt;/P&gt;&lt;P&gt;&amp;gt; This is the reason why it is taking time.&lt;/P&gt;&lt;P&gt;&amp;gt; Use for all entries for second internal table looping.&lt;/P&gt;&lt;P&gt;&amp;gt; Use internal table instead of writing individual workareas in into clause.&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; Edited by: Sreesudha Gullapalli on Feb 6, 2009 9:37 AM&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;can u give me code for that..???&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Feb 2009 08:39:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-problem/m-p/5090031#M1181540</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-06T08:39:04Z</dc:date>
    </item>
    <item>
      <title>Re: select statement problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-problem/m-p/5090032#M1181541</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Nilesh ,&lt;/P&gt;&lt;P&gt;  Yes a better option is to go for &lt;STRONG&gt;joins&lt;/STRONG&gt; (inner or outer) and then validate your entries such that when the record doesnt exist display an error messgae or something .&lt;/P&gt;&lt;P&gt;That you can do it using &lt;STRONG&gt;sy-subrc&lt;/STRONG&gt; .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here s how you can do it using &lt;STRONG&gt;joins&lt;/STRONG&gt; and &lt;STRONG&gt;for all entries&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA:&lt;/P&gt;&lt;P&gt;  t_mara LIKE STANDARD TABLE OF fs_material,&lt;/P&gt;&lt;P&gt;  t_marc LIKE STANDARD TABLE OF fs_material1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT matnr&lt;/P&gt;&lt;P&gt;       mtart&lt;/P&gt;&lt;P&gt;INTO   CORRESPONDING FIELDS OF TABLE t_mara&lt;/P&gt;&lt;P&gt;FROM   mara&lt;/P&gt;&lt;P&gt;WHERE mtart = p_mtart .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;AND EXISTS ( SELECT marc~werks&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;INTO CORRESPONDING FIELDS OF TABLE&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;t_material FROM marc ).&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT matnr&lt;/P&gt;&lt;P&gt;       werks&lt;/P&gt;&lt;P&gt;  FROM marc&lt;/P&gt;&lt;P&gt;  INTO TABLE t_marc FOR ALL ENTRIES&lt;/P&gt;&lt;P&gt;  IN  t_mara&lt;/P&gt;&lt;P&gt; WHERE matnr = t_mara-matnr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope it helps!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Much Regards ,&lt;/P&gt;&lt;P&gt;Amuktha .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Amuktha Naraparaju on Feb 6, 2009 9:44 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Feb 2009 08:43:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-problem/m-p/5090032#M1181541</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-06T08:43:56Z</dc:date>
    </item>
    <item>
      <title>Re: select statement problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-problem/m-p/5090033#M1181542</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;try this &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;declare a structure with vbrk and vbrp table fields.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select a~kunrg &lt;/P&gt;&lt;P&gt;          a&lt;SUB&gt;vbeln a&lt;/SUB&gt;fkdat a&lt;SUB&gt;vbtyp a&lt;/SUB&gt;vkorg a~vtweg &lt;/P&gt;&lt;P&gt;b&lt;SUB&gt;matnr b&lt;/SUB&gt;matkl b&lt;SUB&gt;fkimg b&lt;/SUB&gt;brgew b&lt;SUB&gt;kzwi6 b&lt;/SUB&gt;netwr &lt;/P&gt;&lt;P&gt;into table itab&lt;/P&gt;&lt;P&gt; from vbrk as a inner join vbrp as b &lt;/P&gt;&lt;P&gt;  where a&lt;SUB&gt;kunrg in kunnr and a&lt;/SUB&gt;fkdat in fkdat and a~fksto ne 'X' and&lt;/P&gt;&lt;P&gt; a~ fkart  'ZRO' and a&lt;SUB&gt;vkorg in vkorg and a&lt;/SUB&gt;vtweg in vtweg and a~spart in&lt;/P&gt;&lt;P&gt; spart and vbeln = itab-vbeln.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Feb 2009 08:44:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-problem/m-p/5090033#M1181542</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-06T08:44:35Z</dc:date>
    </item>
    <item>
      <title>Re: select statement problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-problem/m-p/5090034#M1181543</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;Try with this code&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select kunrg &lt;/P&gt;&lt;P&gt;          vbeln &lt;/P&gt;&lt;P&gt;          fkdat&lt;/P&gt;&lt;P&gt;           vbtyp &lt;/P&gt;&lt;P&gt;          vkorg &lt;/P&gt;&lt;P&gt;         vtweg into table itab&lt;/P&gt;&lt;P&gt;        from vbrk&lt;/P&gt;&lt;P&gt;       where kunrg in kunnr and fkdat in fkdat and fksto ne 'X' and&lt;/P&gt;&lt;P&gt;      fkart  'ZRO' and vkorg in vkorg and vtweg in vtweg and spart in&lt;/P&gt;&lt;P&gt;     spart.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;if not itab[] is initial.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;   select matnr matkl fkimg brgew kzwi6 netwr into table itab1&lt;/P&gt;&lt;P&gt;      from vbrp for all entries in itab&lt;/P&gt;&lt;P&gt;       where vbeln = itab-vbeln.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;select name1 vkorg vtweg spart vwerk bzirk kdgrp vkbur into&lt;/P&gt;&lt;P&gt;  from kna1vv for all entries in itab&lt;/P&gt;&lt;P&gt; where kunnr = itab-kunnr and vkorg in vkorg and vtweg in vtweg&lt;/P&gt;&lt;P&gt;and spart in spart.  &lt;/P&gt;&lt;P&gt;endif.&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>Fri, 06 Feb 2009 08:44:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-problem/m-p/5090034#M1181543</guid>
      <dc:creator>former_member404244</dc:creator>
      <dc:date>2009-02-06T08:44:53Z</dc:date>
    </item>
    <item>
      <title>Re: select statement problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-problem/m-p/5090035#M1181544</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;In last select  you  can avoid  name1 .&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Pinaki&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Feb 2009 08:50:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-problem/m-p/5090035#M1181544</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-06T08:50:33Z</dc:date>
    </item>
    <item>
      <title>Re: select statement problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-problem/m-p/5090036#M1181545</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;try thi:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

select a~kunrg a~vbeln a~fkdat a~vbtyp a~vkorg a~vtweg
       b~matnr b~matkl b~fkimg b~brgew b~kzwi6 b~netwr
      c~name1 c~vkorg c~vtweg c~spart c~vwerk c~bzirk c~kdgrp c~vkbur
                INTO CORRESPONDING FIELDS OF TABLE itab
         FROM ( ( vbrk AS a
         INNER JOIN vbrp AS b ON a~vbeln   = b~vbeln  )
                  INNER JOIN kna1vv AS c ON c~kunnr = a~kunnr  )
                  where a~kunrg in kunnr and a~fkdat in fkdat and a~fksto ne 'X' and
                   a~fkart = 'ZRO' and a~vkorg in vkorg and a~vtweg in vtweg and a~spart in
                 spart and c~kunnr in kunnr and c~vkorg in vkorg and c~vtweg in vtweg
                 and c~spart in spart.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;here itab contains all the fields&lt;/P&gt;&lt;P&gt;this is inner join on 3 tables&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Feb 2009 08:52:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-problem/m-p/5090036#M1181545</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-06T08:52:38Z</dc:date>
    </item>
    <item>
      <title>Re: select statement problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-problem/m-p/5090037#M1181546</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello NIlesh,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try this code using INNER JOINS:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA:

BEGIN OF itab OCCURS 0,
kunnr TYPE kunnr,
vbeln TYPE vbeln_vf,
fkdat TYPE fkdat,
vbtyp TYPE vbtyp,
vkorg TYPE vtweg,
matnr TYPE matnr,
matkl TYPE matkl,
fkimg TYPE fkimg,
brgew TYPE brgew_15,
kzwi6 TYPE kzwi6,
netwr TYPE netwr_fp,
name1 TYPE name1,
spart TYPE spart,
vwerk TYPE vwerk,
bzirk TYPE bzirk,
kdgrp TYPE kdgrp,
vkbur TYPE vkbur,
END OF itab.

SELECT
a~kunrg a~vbeln a~fkdat a~vbtyp a~vkorg a~vtweg
b~matnr b~matkl b~fkimg b~brgew b~kzwi6 b~netwr
c~name1 c~spart c~vwerk c~bzirk c~kdgrp c~vkbur
INTO TABLE itab
FROM vbrk AS a INNER JOIN vbrp AS b ON b~vbeln = a~vbeln
               INNER JOIN kna1vv AS c ON c~kunnr = a~kunrg
WHERE
a~kunrg IN kunnr AND
a~fkdat IN fkdat AND
a~fksto NE 'X' AND
a~fkart EQ 'ZRO' AND
a~vkorg IN vkorg AND
a~vtweg IN vtweg AND
a~spart IN spart.

IF sy-subrc = 0.
ENDIF.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BR,&lt;/P&gt;&lt;P&gt;Suhas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Feb 2009 08:59:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-problem/m-p/5090037#M1181546</guid>
      <dc:creator>SuhaSaha</dc:creator>
      <dc:date>2009-02-06T08:59:15Z</dc:date>
    </item>
    <item>
      <title>Re: select statement problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-problem/m-p/5090038#M1181547</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;even if im joining VBRK and VBRP but the thing is that they will have the same o/p it will not solve the prob..&lt;/P&gt;&lt;P&gt;the prob is for every entry from VBRK and VBRP join it shows all the cust. from Masterit shld go into masters table only once and not for every record......&lt;/P&gt;&lt;P&gt;thanx.....&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Feb 2009 09:00:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-problem/m-p/5090038#M1181547</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-06T09:00:26Z</dc:date>
    </item>
    <item>
      <title>Re: select statement problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-problem/m-p/5090039#M1181548</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt; Hi,&lt;/P&gt;&lt;P&gt;&amp;gt; In last select  you  can avoid  name1 .&lt;/P&gt;&lt;P&gt;&amp;gt; Regards&lt;/P&gt;&lt;P&gt;&amp;gt; Pinaki&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;this will solve my prob..?????&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Feb 2009 09:01:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-problem/m-p/5090039#M1181548</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-06T09:01:57Z</dc:date>
    </item>
    <item>
      <title>Re: select statement problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-problem/m-p/5090040#M1181549</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Nilesh,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try below code, i m sure it will work for you..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

DATA : BEGIN OF IT_KNA1 OCCURS 0,
        KUNNR LIKE KNA1VV-KUNNR,
        NAME1 LIKE KNA1VV-NAME1,
        SPART LIKE KNA1VV-SPART ,
        VWERK LIKE KNA1VV-VWERK,
        BZIRK LIKE KNA1VV-BZIRK ,
        KDGRP LIKE KNA1VV-KDGRP,
        VKBUR LIKE KNA1VV-VKBUR,
       END OF IT_KNA1.

DATA : BEGIN OF IT_VBRK OCCURS 0,
        VBELN LIKE VBRK-VBELN ,
        KUNRG LIKE VBRK-KUNRG ,
        FKDAT LIKE VBRK-FKDAT ,
        VBTYP LIKE VBRK-VBTYP ,
        VKORG LIKE VBRK-VKORG ,
        VTWEG LIKE VBRK-VTWEG,
       END OF IT_VBRK.

DATA : BEGIN OF IT_VBRP OCCURS 0,
        VBELN LIKE VBRP-VBELN ,
        POSNR LIKE VBRP-POSNR ,
        MATNR LIKE VBRP-MATNR ,
        MATKL LIKE VBRP-MATKL ,
        FKIMG LIKE VBRP-FKIMG ,
        BRGEW LIKE VBRP-BRGEW ,
        KZWI6 LIKE VBRP-KZWI6 ,
        NETWR LIKE VBRP-NETWR,
       END OF IT_VBRP.

DATA : BEGIN OF IT_FINAL OCCURS 0,
        KUNNR LIKE KNA1VV-KUNNR,
        NAME1 LIKE KNA1VV-NAME1,
        SPART LIKE KNA1VV-SPART ,
        VWERK LIKE KNA1VV-VWERK,
        BZIRK LIKE KNA1VV-BZIRK ,
        KDGRP LIKE KNA1VV-KDGRP,
        VKBUR LIKE KNA1VV-VKBUR,
        VBELN LIKE VBRK-VBELN ,
        VBELP LIKE VBRP-POSNR ,
        KUNRG LIKE VBRK-KUNRG ,
        FKDAT LIKE VBRK-FKDAT ,
        VBTYP LIKE VBRK-VBTYP ,
        VKORG LIKE VBRK-VKORG ,
        VTWEG LIKE VBRK-VTWEG,
        MATNR LIKE VBRP-MATNR ,
        MATKL LIKE VBRP-MATKL ,
        FKIMG LIKE VBRP-FKIMG ,
        BRGEW LIKE VBRP-BRGEW ,
        KZWI6 LIKE VBRP-KZWI6 ,
        NETWR LIKE VBRP-NETWR,
       END OF IT_FINAL.

SELECT KUNNR NAME1 SPART VWERK BZIRK KDGRP VKBUR
INTO TABLE IT_KNA1
FROM KNA1VV
WHERE KUNNR IN KUNNR AND
      VKORG IN VKORG AND
      VTWEG IN VTWEG AND
      SPART IN SPART.

IF IT_KNA1[] IS NOT INITIAL.
  SELECT VBELN KUNRG FKDAT VBTYP VKORG VTWEG
  INTO  TABLE IT_VBRK
  FROM VBRK
  FOR ALL ENTRIES IN IT_KNA1
  WHERE KUNRG =  IT_KNA1-KUNNR AND
        FKDAT IN FKDAT   AND
        FKSTO NE 'X'     AND
        FKART EQ 'ZRO'   AND
        VKORG IN VKORG   AND
        VTWEG IN VTWEG   AND
        SPART IN SPART.
  IF IT_VBRK[] IS NOT INITIAL.
    SELECT VBELN POSNR MATNR MATKL FKIMG BRGEW KZWI6 NETWR
    INTO TABLE IT_VBRP
    FROM VBRP
    FOR ALL ENTRIES IN IT_VBRK
    WHERE VBELN = IT_VBRK-VBELN.
  ENDIF.
  
  LOOP AT IT_KNA1.
    MOVE-CORRESPONDING IT_KNA1 TO IT_FINAL.
    READ TABLE IT_VBRK WITH KEY KUNRG = IT_KNA1-KUNNR.
    IF SY-SUBRC = 0.
      LOOP AT IT_VBRK WHERE KUNRG = IT_KNA1-KUNNR.
        MOVE-CORRESPONDING IT_VBRK TO IT_FINAL.
        LOOP AT IT_VBRP WHERE VBELN = IT_VBRK-VBELN.
          MOVE-CORRESPONDING IT_VBRP TO IT_FINAL.
          APPEND IT_FINAL.
          CLEAR IT_FINAL.
        ENDLOOP.
      ENDLOOP.
    ELSE.
      APPEND IT_FINAL.
      CLEAR IT_FINAL.
    ENDIF.
  ENDLOOP.

ENDIF.


&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Meet&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Feb 2009 09:11:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-problem/m-p/5090040#M1181549</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-06T09:11:32Z</dc:date>
    </item>
    <item>
      <title>Re: select statement problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-problem/m-p/5090041#M1181550</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HI,&lt;/P&gt;&lt;P&gt;You will have to add some more fields in the join of kna1vv. This is because the customer can be maintained for many sales areas and you should look for the customer only under a specific sales area. thus change your query to :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
SELECT
a~kunrg a~vbeln a~fkdat a~vbtyp a~vkorg a~vtweg
b~matnr b~matkl b~fkimg b~brgew b~kzwi6 b~netwr
c~name1 c~spart c~vwerk c~bzirk c~kdgrp c~vkbur
INTO TABLE itab
FROM vbrk AS a INNER JOIN vbrp AS b ON b~vbeln = a~vbeln
               INNER JOIN kna1vv AS c ON c~kunnr = a~kunrg and
                                         c~VKORG = a~VKORG and  
                                         c~VTWEG = a~VTWEG and
                                         c~SPART = a~SPART
WHERE
a~kunrg IN kunnr AND
a~fkdat IN fkdat AND
a~fksto NE 'X' AND
a~fkart EQ 'ZRO' AND
a~vkorg IN vkorg AND
a~vtweg IN vtweg AND
a~spart IN spart.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now the customer record that is valid for the VBRK record will be fetched.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;Advait&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Feb 2009 09:15:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-problem/m-p/5090041#M1181550</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-06T09:15:28Z</dc:date>
    </item>
    <item>
      <title>Re: select statement problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-problem/m-p/5090042#M1181551</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt; HI,&lt;/P&gt;&lt;P&gt;&amp;gt; You will have to add some more fields in the join of kna1vv. This is because the customer can be maintained for many sales areas and you should look for the customer only under a specific sales area. thus change your query to :&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;/CODE&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;CODE&gt;
&amp;gt; SELECT
&amp;gt; a~kunrg a~vbeln a~fkdat a~vbtyp a~vkorg a~vtweg
&amp;gt; b~matnr b~matkl b~fkimg b~brgew b~kzwi6 b~netwr
&amp;gt; c~name1 c~spart c~vwerk c~bzirk c~kdgrp c~vkbur
&amp;gt; INTO TABLE itab
&amp;gt; FROM vbrk AS a INNER JOIN vbrp AS b ON b~vbeln = a~vbeln
&amp;gt;                INNER JOIN kna1vv AS c ON c~kunnr = a~kunrg and
&amp;gt;                                          c~VKORG = a~VKORG and  
&amp;gt;                                          c~VTWEG = a~VTWEG and
&amp;gt;                                          c~SPART = a~SPART
&amp;gt; WHERE
&amp;gt; a~kunrg IN kunnr AND
&amp;gt; a~fkdat IN fkdat AND
&amp;gt; a~fksto NE 'X' AND
&amp;gt; a~fkart EQ 'ZRO' AND
&amp;gt; a~vkorg IN vkorg AND
&amp;gt; a~vtweg IN vtweg AND
&amp;gt; a~spart IN spart.
&amp;gt; 
&amp;gt; &lt;/CODE&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; Now the customer record that is valid for the VBRK record will be fetched.&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; regards,&lt;/P&gt;&lt;P&gt;&amp;gt; Advait&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; i want ALL THE RECORDS from MASTER they r matching or not.....&lt;/P&gt;&lt;P&gt;i have aslready mentioned this before....&lt;/P&gt;&lt;P&gt;thanx......&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Feb 2009 09:23:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-problem/m-p/5090042#M1181551</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-06T09:23:51Z</dc:date>
    </item>
    <item>
      <title>Re: select statement problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-problem/m-p/5090043#M1181552</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thanxx but not the single code from the above replies is working fine .....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanxx...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Feb 2009 09:24:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-problem/m-p/5090043#M1181552</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-06T09:24:46Z</dc:date>
    </item>
    <item>
      <title>Re: select statement problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-problem/m-p/5090044#M1181553</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think you have managed to confuse us everyone -:). Your requirements are not clear , may be it is better to put an example and explain what you are expecting.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I dont understand , if you need customer master data why would you search VBRK and VBRP ? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Anyways , if you can avoid using the above tables, then try to use &lt;STRONG&gt;Delete adjacent duplicates by comparing the fields for which you want a unique record to be displayed&lt;/STRONG&gt;. Do this after the select.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;Advait&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Feb 2009 09:35:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-problem/m-p/5090044#M1181553</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-06T09:35:56Z</dc:date>
    </item>
    <item>
      <title>Re: select statement problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-problem/m-p/5090045#M1181554</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Nilesh,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try to replace your code with mine,&lt;/P&gt;&lt;P&gt;it will work fine for you..&lt;/P&gt;&lt;P&gt;I think you need to add / remove some fields in tables but method will be run as per your requirement..&lt;/P&gt;&lt;P&gt;As you need all datas from customer master and based on this you need data from VRK and VBRP,&lt;/P&gt;&lt;P&gt;from this code you will able to get it..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Meet&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Feb 2009 09:43:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-problem/m-p/5090045#M1181554</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-06T09:43:20Z</dc:date>
    </item>
    <item>
      <title>Re: select statement problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-problem/m-p/5090046#M1181555</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt; I think you have managed to confuse us everyone -:). Your requirements are not clear , may be it is better to put an example and explain what you are expecting.&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; I dont understand , if you need customer master data why would you search VBRK and VBRP ? &lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; Anyways , if you can avoid using the above tables, then try to use &lt;STRONG&gt;Delete adjacent duplicates by comparing the fields for which you want a unique record to be displayed&lt;/STRONG&gt;. Do this after the select.&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; regards,&lt;/P&gt;&lt;P&gt;&amp;gt; Advait&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;c im not confused at all and i dont want to ...&lt;/P&gt;&lt;P&gt;thats why i paste my code also there ...so that all have clear idea...&lt;/P&gt;&lt;P&gt;and i dont just want the cust master data if i wanted that i wolud used VBRK and VBRP&lt;/P&gt;&lt;P&gt;again im explaining &lt;/P&gt;&lt;P&gt;like ..&lt;/P&gt;&lt;P&gt;cust    sales org.  mat    date&lt;/P&gt;&lt;P&gt;1100     s1           m1    mmyy&lt;/P&gt;&lt;P&gt;1100     s2                   &lt;/P&gt;&lt;P&gt;1100     s3          m2     mmyy&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;here cust from s2 sales org didnt have sale so its blank and this can be available from master only&lt;/P&gt;&lt;P&gt;THATS WHY IM USING CUST MASTER...&lt;/P&gt;&lt;P&gt;and other 2 recds r getting me from VBRK &amp;amp; VBRP&lt;/P&gt;&lt;P&gt;but the code which i have given is giving me correct records but only the prob of appending &lt;/P&gt;&lt;P&gt;the master records are eppending each time for every record from VBRK and VBRP&lt;/P&gt;&lt;P&gt;i think now u ppl should get....&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Feb 2009 10:04:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-problem/m-p/5090046#M1181555</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-06T10:04:43Z</dc:date>
    </item>
    <item>
      <title>Re: select statement problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-problem/m-p/5090047#M1181556</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt; Hi Nilesh,&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; Try to replace your code with mine,&lt;/P&gt;&lt;P&gt;&amp;gt; it will work fine for you..&lt;/P&gt;&lt;P&gt;&amp;gt; I think you need to add / remove some fields in tables but method will be run as per your requirement..&lt;/P&gt;&lt;P&gt;&amp;gt; As you need all datas from customer master and based on this you need data from VRK and VBRP,&lt;/P&gt;&lt;P&gt;&amp;gt; from this code you will able to get it..&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; Regards,&lt;/P&gt;&lt;P&gt;&amp;gt; Meet&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;plzzzz give me the final exact code. u can do modification in my code also that will be good for u and mee too.&lt;/P&gt;&lt;P&gt;thanx...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: NILESH S. on Feb 6, 2009 11:05 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Feb 2009 10:05:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statement-problem/m-p/5090047#M1181556</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-06T10:05:33Z</dc:date>
    </item>
  </channel>
</rss>

