‎2012 Mar 17 11:12 AM
Hi,
I have a select statement on table FMFCTRT which is hitting the performance badly in my report which is called inside a BSEG table loop. I have included all the primary keys in the where condition still I do not see the difference in performance. Can anyone check and see if this is a optimized select statement on FMFCTRT table ?
SELECT BESCHR INTO LS_FILSTRU-BESCHR
UP TO 1 ROWS FROM FMFCTRT
WHERE SPRAS = SY-LANGU
AND FIKRS = L_FIKRS
AND FICTR = LS_FILSTRU-FISTL
AND DATBIS => LS_FILSTRU-BLDAT.
Regards
Praneeth
‎2012 Mar 17 7:35 PM
Hi,
Remove select statement if its inside the loop. Write before looping.
Then use READ TABLE inside your bseg loop to read respective entries from your FMFCTRT internal table.
Hope this helps.
‎2012 Mar 17 10:23 PM
Hello
Avoid using select inside Loop as mentioned by Vinit. Apart from this check the database statistics in DB20 for the table and ask your basis team to update the same if its needed.
Br,
Vijay V
‎2012 Mar 19 3:03 PM
Well, I would use a SELECT SINGLE rather than UP TO 1 ROWS, but I don't think that is your problem. Check you SELECT on BSEG.
Also - how many records in the BSEG loop?
Rob
‎2012 Mar 20 4:49 AM
Hi,
Just as Vinit said: Remove SELECT STATEMENT inside the loop. Get it before looping using FOR ALL ENTRIES then in your looping use READ TABLE.
Regards,
Jake
‎2012 Mar 20 2:35 PM
I really don't think having the SELECT in the LOOP is the problem.
It's more likely that the BSEG internal table has multiple entries for the same value of the primary keys. So the samne SELKECT is done over and over for no particular reason.
Only do the SELECT once for each unique value of the primary key.
Rob
‎2012 Mar 20 2:58 PM
I also think you should not use the select within a loop. For every entry in the loop a database select is performed. Better is to select all entries at once and use a read.
Furthermore, when you are only dealing with cleared items, open iotems or customer items, you should consider to use the tabel BSIS, BSAS or BSID instead, since they are for that purpose.