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

Select query takes long time....

Former Member
0 Likes
716

Hi Experts,

I am using a select query in which inspection lot is in another table and order no. is in another table. this select query taking very long time, what is the problem in this query ? Pl. guide us.

select bPRUEFLOS bMBLNR bCPUDT aAUFNR amatnr aLGORT a~bwart

amenge aummat asgtxt axauto

into corresponding fields of table itab

*into table itab

from mseg as a inner join qamb as b

on amblnr = bmblnr

and azeile = bzeile

where b~PRUEFLOS in insp

and b~cpudt in date1

and b~typ = '3'

and a~bwart = '321'

and a~aufnr in aufnr1.

Yusuf

8 REPLIES 8
Read only

Former Member
0 Likes
683

Hi Yusuf,

Also put MJAHR in selection criteria, as the same document can exist in many years. USE the following

select bPRUEFLOS bMBLNR bCPUDT aAUFNR amatnr aLGORT a~bwart

amenge aummat asgtxt axauto

into corresponding fields of table itab

*into table itab

from mseg as a inner join qamb as b

on amblnr = bmblnr

on amjahr = bmjahr

and azeile = bzeile

where b~PRUEFLOS in insp

and b~cpudt in date1

and b~typ = '3'

and a~bwart = '321'

and a~aufnr in aufnr1.

If it takes a lot of time then make a view comprising of MSEG and QAMB containing all the fields.

Regards,

Mallick

Read only

0 Likes
683

Hi Mallick,

What is View comprising ? How to make it ?

Pl.

Yusuf.

Read only

Former Member
0 Likes
683

Hi,

What is the structure of ITAB. If it is in same order as fields selected in the select query use INTO TABLE ITAB instead of INTO CORRESPONDING FIELDS OF TABLE ITAB.

If it is not of the same order then define another internal table with same order of fields and use in select query.

Into corresponding fields degrades performance of the program.

Never use INTO CORRESPONDING FIELDS...

REgards,

Sankar

Read only

0 Likes
683

Hi Sankar,

I Have removed Corresponding but eventhough it takes long time ?

Yusuf

Read only

Former Member
0 Likes
683

hi

instead of using 'move to corresponding of itab' fields use 'into table itab'.....

coz......if u use move to corresponding it will search for all the appropriate fields then it will place u r data........instead of that declare apprpiate internal table and use 'into table itab'.

and one more thing dont use joins ......coz joins will decrease u r performance .....so instead of that use 'for all entries' ....and mention all the key fields in where condition ........

ok

reward points for helpful answers

Read only

Former Member
0 Likes
683

Solved.

Read only

Former Member
0 Likes
683

reward points if helpful

Read only

Former Member
0 Likes
683

Hi,

The main problem in your code is ur using inner join syntax and fields which is using in on "amblnr = bmblnr and azeile = bzeile" are not Key fields in other table is QUMB, its leads highly perforamnce issue.

you can use the FOR ENTRIES concept inseady of joins.

and you have to give the key fields in where condition for a table MSEG, this tabel contain huge data. so while getting date use always key fields in where condition and maintain sequence..

Reward with points if it useful.

Regards,

Vijay