Skip to Content
author's profile photo Former Member
Former Member

performance of Select using between and in

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Dec 24, 2007 at 01: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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.