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
644

Hi All,

I have a problem with innerjoin...whenever i m writing innerjoin our server getting slow.if i stop it ...it is working fine..is there any problm with innerjoin...does writing wrong join effect sys performance..?

Regards

Sameer

6 REPLIES 6
Read only

Former Member
0 Likes
619

Hi ,

for that there r more reasons r there ,

1. in u r inner join more tables u have used

2. in u inner join u used master tables (more data )

3. try to use For all entries logic

THX

Read only

Former Member
0 Likes
619

Hi, give me your code which u use for inner join. Most cases is u may use lot of tables in that.

Suku

Read only

Former Member
0 Likes
619

HI,

if u r not writing the correct join you will not get wanted records.

Join the columns carrname, connid, fldate of the database tables scarr, spfli and sflight by means of two inner joins. A list is created of the flights from p_cityfr to p_cityto. Alternative names are used for every table.

PARAMETERS: p_cityfr TYPE spfli-cityfrom,

p_cityto TYPE spfli-cityto.

DATA: BEGIN OF wa,

fldate TYPE sflight-fldate,

carrname TYPE scarr-carrname,

connid TYPE spfli-connid,

END OF wa.

DATA itab LIKE SORTED TABLE OF wa

WITH UNIQUE KEY fldate carrname connid.

SELECT ccarrname pconnid f~fldate

INTO CORRESPONDING FIELDS OF TABLE itab

FROM ( ( scarr AS c

JOIN spfli AS p ON pcarrid = ccarrid

AND p~cityfrom = p_cityfr

AND p~cityto = p_cityto )

JOIN sflight AS f ON fcarrid = pcarrid

AND fconnid = pconnid ).

LOOP AT itab INTO wa.

WRITE: / wa-fldate, wa-carrname, wa-connid.

ENDLOOP.

Plzz reward points if it helps.

Read only

Former Member
0 Likes
619

Hi,

For performance issue check the following link:

http://www.sapbrainsonline.com/ARTICLES/TECHNICAL/optimization/optimization.html

Regards,

Bhaskar

Read only

Former Member
0 Likes
619

Thank u for ur reply.....

Finally i came to one conclusion that if we writes wrong code

in inner joins if effects the system performance..then and there itself..In my case i did a small mistake and our server CPU usage drastically increased..

Please correct me if i m wrong..

my wrong code was.

select a~ebeln

a~bedat

a~lifnr

b~ebelp

b~txz01

b~matnr

b~netwr

b~pstyp

into corresponding fields of table it_ekko

from ekko as a inner join ekpo as b

on aekko-ebeln = bekpo-ebeln

where ebeln in s_ebeln

and bedat in s_bedat

and werks in s_werks.

i corrected it as below.

select a~ebeln

a~bedat

a~lifnr

b~ebelp

b~txz01

b~matnr

b~netwr

b~pstyp

into corresponding fields of table it_ekko

from ekko as a inner join ekpo as b

on aebeln = bebeln

where a~ebeln in s_ebeln

and a~bedat in s_bedat

and b~werks in s_werks.

thanx.

Read only

arpit_shah
Contributor
0 Likes
619

hi..sameer..

try to use for all enteries ,

if ur inner join is not working ,

e.g

i m giving one example how to use for all entries.

select lvbeln lposnr lvgbel lmatnr tmaktx lcharg llfimg lumvkz lmeins lvrkme

kwadat_ist kkunag kkunnr nname2 " l~pstyv

into corresponding fields of table atab

from ( lips as l

inner join likp as k on lvbeln = kvbeln

inner join kna1 as n on nkunnr = kkunnr

inner join makt as t on tmatnr = lmatnr )

where ( l~vbeln in dno

and wadat_ist in agi

and charg in batch

and posnr like '9%'

and l~matnr in mt ).

if sy-subrc eq 0.

select kvbeln kstceg pvgbel pvgpos "kkunag "pvbeln

into corresponding fields of table aatab

from vbrk as k

inner join vbrp as p on kvbeln = pvbeln

for all entries in atab

where "k~fkdat in date

kvbtyp = 'U' and pvgtyp = 'J'

and p~vgbel = atab-vbeln.

endif.

OR

select belnr gjahr budat

into corresponding fields of table t_head_expense

from bkpf

where budat in posdate

.

select belnr buzei gjahr hkont dmbtr shkzg sgtxt

into corresponding fields of table t_expense

from bseg

for all entries in t_head_expense

where belnr = t_head_expense-belnr and gjahr = t_head_expense-gjahr.

i hope it is helpful to u.

Regards,

Arpit