Hi,
Q1) How to improve performance for below SELECT statement ?
It only fails at first execution of the day but all subsequent executions are successful. (using same variant all time).
Q2) It might be reading records from db buffer from second execution onward. Can I clear that buffer so that I can test my program from second execution onward?
-Below statement is for selection material documents for given range of years, department for movement types 201, 101, 261.
-I_MATNR contains materials, plants fetched from a custom table for the given department (user defined list of departments)
- I_DOCUMENT_LOW is minimum document number for given year range (from MSEG). It is only used to make use of field MBLNR and to minimize selection.
CHECK NOT ( I_MATNR[] IS INITIAL ).
SELECT MATNR WERKS MSEG~MBLNR BWART MJAHR
INTO TABLE I_MAT_TEMP1
FROM MSEG
FOR ALL ENTRIES IN I_MATNR
WHERE MSEG~MATNR = I_MATNR-MATNR AND
MSEG~WERKS = I_MATNR-WERKS AND
MSEG~MBLNR GE I_DOCUMENT_LOW AND
MSEG~MJAHR BETWEEN CURRENT_YEAR AND LAST_YEAR AND
MSEG~BWART IN ('101', '201', '261' ).
IF NOT ( I_MAT_TEMP1[] IS INITIAL ).
SELECT MBLNR MJAHR BUDAT INTO TABLE I_MKPF FROM MKPF
FOR ALL ENTRIES IN I_MAT_TEMP1
WHERE MBLNR = I_MAT_TEMP1-MBLNR AND
MJAHR = I_MAT_TEMP1-MJAHR AND
BUDAT BETWEEN S_LOW AND S_HIGH.
ENDIF.
There is an index defined in table for following fields :
MATNR
WERKS
LGORT
BWART
SOBKZ
but user doesn't want any selection to be given for field LGORT at selection screen. Again I won;t be using field SOBKZ.
Thanks.
Edited by: Prasad Ganegaonkar on Jan 3, 2008 12:37 PM