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

Program got slow in select statment.

Former Member
0 Likes
914

Hi,

I have written the following select statement:

select name secu from trdir into table it_tab

where name in s_name

and subc eq '1'or subc eq 'I' or subc eq 'F'

and udat in s_date.

I just added this and subc eq '1'or subc eq 'I' or subc eq 'F' and since then the program is taking lot of time... so can you please tell me what wrong I am doing..

Thanks,

Rajeev

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
857

that or is ur problem... OR makes different selects and merge the data...

try to put those ORs in between '(' ')'

also

try to remove the OR and use subc in ('1','I' ,'F')

also try not puting subc in the select and fillter them after the select.

see which one makes ur performace better

Edited by: soumya prakash mishra on Jun 18, 2009 8:02 PM

5 REPLIES 5
Read only

Former Member
0 Likes
858

that or is ur problem... OR makes different selects and merge the data...

try to put those ORs in between '(' ')'

also

try to remove the OR and use subc in ('1','I' ,'F')

also try not puting subc in the select and fillter them after the select.

see which one makes ur performace better

Edited by: soumya prakash mishra on Jun 18, 2009 8:02 PM

Read only

former_member723628
Active Participant
0 Likes
857

Rajeev,

Your Select statement is ambiguous which might be causing the delay.


I have written the following select statement:

select name secu from trdir into table it_tab 
where name in s_name 
and subc eq '1'or subc eq 'I' or subc eq 'F'
and udat in s_date.

Try modifying the query as follows and check.



SELECT name
       secu
  INTO TABLE it_tab
  FROM trdir
 WHERE name IN s_name
   AND ( subc EQ '1' OR 
         subc EQ 'I' OR 
         subc EQ 'F'    )
   AND udat IN s_date.

It's recommended that whenever you use a combination of AND and OR clause to set the precedence of execution brackets should be used.

Regards,

Gajendra

Read only

0 Likes
857

Hi Gajendra,

It didn't help... rather it's giving me an error that field subc EQ '1' OR subc EQ 'I' or subc EQ 'F' is unknown, it is neither in one of the specified tables nor defined by a data statament.

Read only

0 Likes
857

Rajeev,

I have tested this snippet in my test environment and it works fine for me. Try to copy paste the code as it is in your program and see. Make sure that you a space between the openning bracket "(" bracket and field SUBC and a space between 'F' and closing bracket ")" the way I have it in my snippet.

Regards,

Gajendra

Read only

Former Member
0 Likes
857

Hi Rajeev,

Try following select statement.

ranges: r_subc for trdir-subc.

r_subc-option = 'EQ'.

r_subc-sign = 'I'.

r_subc-low = '1'.

append r_subc.

clear r_subc-low.

r_subc-low = 'I'.

append r_subc.

clear r_subc-low.

r_subc-low = 'F'.

append r_subc.

clear r_subc-low.

select name

secu

subc -


Add this field in it_tab as well

from trdir

into table it_tab

where name in s_name

and udat in s_date.

if sy-subrc eq 0.

delete it_tab where subc not in r_subc.

endif.

Regards,

Anil Salekar