I have written one query to select data from BSEG table, but it is taking too much time to execute (40 sec per record) . I want to improve the performance of it. Please suggest the solutions. Query is below.
SELECT * FROM bseg INTO CORRESPONDING FIELDS OF wa_itab
WHERE matnr IN matnr
AND werks IN werks
AND bschl IN ('99' , '89' , '86' , '96')
AND ( ktosl IN ('BSX' , 'PRD')
OR sgtxt = 'Debit/credit to a material from a price change' ).
SELECT SINGLE cpudt cputm budat blart bldat AWKEY FROM bkpf INTO CORRESPONDING FIELDS OF wa_itab
WHERE blart IN ('RE' , 'PR')
AND belnr = wa_itab-belnr.
wa_itab-pperiod = wa_itab-budat(6).
APPEND wa_itab TO itab.
Should I create secondory index on bseg or something else?