2007 Dec 24 1:29 PM
Hi all,
I have the select statement as follows.
SELECT matnr wkgbtr kstar FROM coep INTO wa_wkgbtr1
WHERE kokrs = 'KBX'
AND perio = v_period
AND parob1 = v_con_pkosa
AND gjahr = v_gjahr
AND ( kstar >= '0000003200' AND kstar <= '0000003299' OR
kstar = '0000003100' OR
kstar = '0000043002' OR
kstar = '0000001100' OR
kstar = '0000043011' OR
kstar = '0000041001' OR
kstar = '0000041011' OR
kstar = '0000041021' OR
kstar = '0000043021' OR
kstar = '0000044631' OR
kstar = '0000041501' OR
kstar = '0000041502'
).
can we use Between and IN operators to improve its performance.
as I have used it as below
SELECT matnr wkgbtr kstar FROM coep INTO TABLE it_wkgbtr1
FOR ALL ENTRIES IN IT_TEMP
WHERE kokrs = it_temp-kokrs
AND perio = it_temp-perio
AND gjahr = it_temp-gjahr
AND parob1 = it_temp-parob1
AND kstar BETWEEN '0000003200' AND '0000003299' OR
kstar IN ('0000003100','0000043002','0000001100','0000043011','0000041001','0000041011','0000041021','0000043021','0000044631','0000041501','0000041502').
but it is taking very long time. Can anybody please fine tune the select sttement.
Thanks in advance
2007 Dec 24 1:39 PM
create a range table for KSTAR.
DATA : begin of s_kstar,
sign(1),
option(2),
low like coep-kstar,
high like coep-kstar,
end of s_kstar.
s_kstar-sign = 'I'.
s_kstar-option = 'BT'.
s_kstar-low = '0000003200'.
s_kstar-hig = '0000003299'.
append s_kstar.
clear s_kstar.
s_kstar-sign = 'I'.
s_kstar-option = 'EQ'.
s_kstar-low = '0000003100'.
append s_kstar.
do it for all values of kstar.
ad change select query to select....... IN S_KSTAR.
Reward if useful
Regards
ANUPAM
2007 Dec 24 1:39 PM
create a range table for KSTAR.
DATA : begin of s_kstar,
sign(1),
option(2),
low like coep-kstar,
high like coep-kstar,
end of s_kstar.
s_kstar-sign = 'I'.
s_kstar-option = 'BT'.
s_kstar-low = '0000003200'.
s_kstar-hig = '0000003299'.
append s_kstar.
clear s_kstar.
s_kstar-sign = 'I'.
s_kstar-option = 'EQ'.
s_kstar-low = '0000003100'.
append s_kstar.
do it for all values of kstar.
ad change select query to select....... IN S_KSTAR.
Reward if useful
Regards
ANUPAM