Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Inner join

Former Member
0 Likes
1,239

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

7 REPLIES 7
Read only

Former Member
0 Likes
900

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

Read only

Former Member
0 Likes
900

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

Read only

0 Likes
900

Jay - that's incorrect. JOINs usually outperform FOR ALL ENTRIES.

Bear in mind that ABAP implements views using JOINs.

Rob

Read only

Former Member
0 Likes
900

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.

Read only

0 Likes
900

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

Read only

0 Likes
900

Hi Kamala,

Will u explain me clearly...

thansk & regards

sankar.

Read only

0 Likes
900

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