‎2007 Aug 24 9:56 AM
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
‎2007 Aug 24 10:13 AM
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
‎2007 Aug 24 10:17 AM
Hi Mallick,
What is View comprising ? How to make it ?
Pl.
Yusuf.
‎2007 Aug 24 10:18 AM
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
‎2007 Aug 24 10:37 AM
Hi Sankar,
I Have removed Corresponding but eventhough it takes long time ?
Yusuf
‎2007 Aug 24 10:37 AM
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
‎2007 Aug 24 10:43 AM
‎2007 Aug 27 7:29 AM
‎2007 Aug 27 10:44 AM
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