‎2008 Feb 14 9:48 AM
Hi Friends,
pls check the below code and help me to know how to relate the table of vbak and vbrp.....for return orders in the same stmt.
I've used the inner join stmt and it displays the report other than the return orders of sales....if i add to display the return delivery reports...it can doable via vbak->vbrp join....
FYI
if i use the 'INNER JOIN vbrp on vbakvbeln eq vbrpvgbel instead of 'INNER JOIN vbrp on lipsvbeln eq vbrpvgbel' then the whole report goes duplication while appending.....
and in inner join, we can't use OR conditions.....
(the below replies not solving my problem 14/2/08)
pls advise.
*****coding
SELECT vbakvbeln vbakerdat vbakkunnr kna1name1 lips~vbeln
vbrp~vbeln
maktmaktx vbrpmatnr vbrpfkimg vbrpnetwr VBAKAUART VBRPWERKS
INTO TABLE i_sales
FROM vbak
inner join vbap on vbakvbeln eq vbapvbeln
INNER JOIN vbpa ON vbakvbeln EQ vbpavbeln
INNER JOIN lips ON vbakvbeln EQ lipsvgbel
INNER JOIN vbrp on lipsvbeln eq vbrpvgbel
inner join kna1 on vbakkunnr eq kna1kunnr
inner join makt on vbrpmatnr eq maktmatnr
WHERE vbpaparvw EQ 'AG' and lipsposnr eq vbrpvgpos and vbakvkorg in l_salorg
and vbakvtweg in l_chanel and vbakspart in l_dvsn and vbak~erdat in l_date and
vbrpmatnr in l_matnr and VBAKAUART IN L_AUART AND vbrp~werks in l_werks.
thanks & regards
sankar.
Edited by: Alvaro Tejada Galindo on Feb 14, 2008 2:07 PM
Edited by: sankar babu on Feb 15, 2008 2:57 PM
‎2008 Feb 14 11:13 AM
START-OF-SELECTION.
select akunag avbeln afkdat abukrs a~vbtyp
bmatkl bmatnr barktx bfkimg bkzwi2 bwavwr
c~name1
d~kunn2
into corresponding fields of table replines
from vbrk as a
inner join vbrp as b
on avbeln = bvbeln
inner join kna1 as c
on akunag = ckunnr
left outer join knvp as d
on akunag = dkunnr and
avkorg = dvkorg and
avtweg = dvtweg and
d~spart = '71' and
d~parvw = 'CO' and
d~parza = '000'
where a~vkorg = '7100' and
a~vbtyp in r_vtyp and
a~fkdat in s_date and
a~kunag in s_cust and
b~matkl in s_mgrp and
b~autyp in r_atyp.
END-OF-SELECTION
<REMOVED BY MODERATOR>
regards,
priya.
Edited by: Alvaro Tejada Galindo on Feb 14, 2008 2:07 PM
‎2008 Feb 14 11:25 AM
Hi.
Dont use Inner joint,mostly we need to avoid use inner join,its not optimiz,use All entries.
try this code.
Select vbeln erdat kunnr AUART from VBRK into IT_VBRK .
Select vbeln matnr fkimg netwr WERKS from VBRP into IT_VBRP for all entries in it_vbrk where vbeln eq it_vbak-vbeln.
Select vbeln from LIPS into it_lips for all entries in it_vbrp where vbeln = it_vbrp-vgbel.
Select kunnr name1 from KAN1 into IT_KNA1 for all entries IT_VBAK where kunnr = it_vbrk-kunnr.
Select matnr from makt into it_makt for all entries in it_vbrb where matnr = it_vbrp-matnr.
<REMOVED BY MODERATOR>
Jay
Edited by: Alvaro Tejada Galindo on Feb 14, 2008 2:08 PM
‎2008 Feb 14 7:12 PM
Jay - that's incorrect. JOINs usually outperform FOR ALL ENTRIES.
Bear in mind that ABAP implements views using JOINs.
Rob
‎2008 Feb 15 2:08 PM
Hi,
You are using somany tables in innerjoins.
If you do for more than 3 joins, the performance wise it is not good. First you join 3 tables. then for all entries of that table select from other tables.
regards,
kamala.
‎2008 Feb 15 2:16 PM
Hi Rob,
Even in my opinion for all entries is better performance wise than join. A simple reason behind this is the time for which your database access remains open. This palys major role when your tables ahve huge data. It is quiet possible that your join statement might go in dump in case of huge data.
Regards,
Siddhesh S.Tawate
‎2008 Feb 15 2:29 PM
‎2008 Feb 15 2:50 PM
Siddhesh - please see:
[JOINS vs. FOR ALL ENTRIES - Which Performs Better?|/people/rob.burbank/blog/2007/03/19/joins-vs-for-all-entries--which-performs-better]
or
[FOR ALL ENTRIES vs DB2 JOIN|http://blogs.ittoolbox.com/sap/db2/archives/for-all-entries-vs-db2-join-8912]
Rob