Skip to Content
0
Former Member
Jan 08, 2008 at 01:00 PM

KNVV and KNA1 join

1947 Views

Dear All,

I am working on a KNVV and KNA1 join. Given below are the figures and requirements.

My requirement is to select all the customers and their related sales offices from KNVV & KNA1 join where customer should be a sold-to-party (KTOKD = 0001).

kna1: 8643029 records and if I take only sold-to-party into account then total 1247420 records (where KTOKD = 0001).

knvv: 8643029 records

My code as below:

data: begin of itab occurs 50000,

vkbur type vkbur,

kunnr type kunnr,

end of itab.

select knvvvkbur kna1kunnr from knvv inner join kna1

on knvvmandt = kna1mandt

and knvvkunnr = kna1kunnr

into table itab where knvv~vkbur = 'VKBUR'

and kna1~ktokd = '0001'.

now for my sales office VKBUR, there are total 170421, but the resultant set is 50000 records. and for this select execution time taken is 11 - 15 minutes.

if i write the join in a reverse way, then also the execution takes 13 - 15 minutes. kna1 join knvv as below:

select kna1kunnr knvvvkbur from kna1 inner join knvv

on kna1mandt = knvvmandt

and kna1kunnr = knvvkunnr

into table itab where kna1~ktokd = '0001'

and knvv~vkbur = 'VKBUR'.

if anybody could finetune the above stated situation.

Regards

Bhanu