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,373

SELECT kna1kunnr kna1ktokd INTO TABLE i_kna1keym

FROM ( kna1 INNER JOIN knvv ON kna1kunnr = knvvkunnr )

WHERE kna1~kunnr IN s_kunnr AND

knvv~vkorg IN s_vkorg AND

kna1~ktokd IN r_ktokd AND

kna1~ktokd IN s_ktokd.

this is taking long time can any one help me how to make it faster.

10 REPLIES 10
Read only

Former Member
0 Likes
1,129

Is the field KTOKD on on the index. If not you may be best to extract this field into your internal table then filter the records out from that. Also remove the condition from your select statement.

I also notice that you are check the value of KTOKD in two separate range tables.

Read only

Former Member
0 Likes
1,129

Joins statements in your select would easily consume your time. I would suggest you to dump the data from both tab;es separately into 2 internal tables and then use your conditions to filter the records.

-

santosh

Read only

Former Member
0 Likes
1,129

here why are you using kna1~ktokd two times i dont know... if you want to append some conditon you can append that in your selectoption also then why the range is there.

regards

shiba dutta

Read only

Former Member
0 Likes
1,129

1 SELECT kna1kunnr kna1ktokd INTO TABLE i_kna1keym

2 FROM ( kna1 INNER JOIN knvv ON kna1kunnr = knvvkunnr )

3 WHERE kna1~kunnr IN s_kunnr AND

4 knvv~vkorg IN s_vkorg AND

5 kna1~ktokd IN r_ktokd AND

6 kna1~ktokd IN s_ktokd.

Whats the difference between 5th and 6th line.Can you please check it out.

Regards,

Read only

Former Member
0 Likes
1,129

but the condition i am using is needed its extracting the data from only one table

Read only

Former Member
0 Likes
1,129

Your final fetch is ktokd from KNA1.

1.

select 1 into itab.

You can make use of table TVKO + KNVV for identifying the customer in the sales area .

2. for all entries of itab select 2 from kna1 into jtab with KTokd .

make use of this logic .

3.

making use of index also is one quick access but u need to get approval for that if u get it then its okay else go with the logic .

You are doing validation on two tables one for sales orgnization with no matching primary /foreign keys to have a faster access.

so decrease the time access by tvko and knvv

next get the kna1-ktokd field with a single acces .

regards,

vijay

Read only

Former Member
0 Likes
1,129

Try to change your code as below.

select kunnr ktokd from kna1 into table i_kna1keym
from kna1
where kunnr in ( select kunnr from knvv where kunnr in s_kunnr
                                                         and vkorg in s_vkorg)
and ktokd in r_ktokd
and ktokd in s_ktokd.

Also try to replace the two selection parameters for ktokd with one.

Manoj

Read only

0 Likes
1,129

i am getting error in the code

Read only

Former Member
0 Likes
1,129

Hi ,

Append r_ktokd dats into s_ktokd

or

Append s_ktokd dats into r_ktokd

and use any one in the select statement.

Regards,

Ashok kumar.

Read only

Former Member
0 Likes
1,129

Try to use more key fields in the where condiiton like VKORG VTWEG