2007 Sep 03 7:04 AM
Hi,
I am pasting the code which i have used to access the database, i m displaying the report in alv format....when i checked it in se30 the results for database access are quite high...how can i optimize the performance.......
SELECT KUNNR
NAME1
INTO TABLE IT_KNA1
FROM KNA1
WHERE KUNNR IN S_KUNNR.
SELECT VBELN
KNUMV
KUNNR
INTO TABLE IT_VBAK
FROM VBAK
FOR ALL ENTRIES IN IT_KNVV
WHERE SPART = IT_KNVV-SPART
AND KUNNR = IT_KNVV-KUNNR.
IF SY-DBCNT = 0.
MESSAGE E001(Z_MESG).
ENDIF.
SELECT KNUMV
KSCHL
KAWRT
INTO TABLE IT_KONV
FROM KONV
FOR ALL ENTRIES IN IT_VBAK
WHERE KNUMV = IT_VBAK-KNUMV.
SELECT VBELN
MATNR
ARKTX
WERKS
NETPR
INTO TABLE IT_VBAP
FROM VBAP
FOR ALL ENTRIES IN IT_VBAK
WHERE WERKS IN S_WERKS
AND MATNR IN S_MATNR
AND VBELN = IT_VBAK-VBELN.
IF SY-DBCNT = 0.
MESSAGE I002(Z_MESG) with s_werks s_matnr.
ENDIF.
SELECT VBELN
FKIMG
NETWR
AUBEL
PRCTR
INTO TABLE IT_VBRP
FROM VBRP
FOR ALL ENTRIES IN IT_VBAP
WHERE AUBEL = IT_VBAP-VBELN.
SELECT VBELN
VGBEL
INTO TABLE IT_LIPS
FROM LIPS
FOR ALL ENTRIES IN IT_VBAP
WHERE VGBEL = IT_VBAP-VBELN.
SELECT DMBTR
XBLNR
INTO TABLE IT_BSIS
FROM BSIS
FOR ALL ENTRIES IN IT_LIPS
WHERE ( HKONT = '0004111013' OR HKONT = '0004111008' OR HKONT = '0004111009' )
AND BUDAT IN S_BUDAT
AND XBLNR = IT_LIPS-VBELN.
IF SY-DBCNT = 0.
MESSAGE I003(Z_MESG) with S_BUDAT.
ENDIF.
2007 Sep 03 7:09 AM
1. Replace your FOR ALL ENTRIES by RANGES
2. If you would like to use FOR ALL ENTRIES, try to prepare the internal table with only one entry by key (ex the select on KONV, KNUMV is not the key of IT_VBAK, so you will access several times the same key in the database).
I think your reponse time problem is due to the FOR ALL ENTRIES. If you make an ST05 you will show that this command make several access instead of a simple RANGES.
Sometimes it's better to access all the table than select requiered entry (for ex. KNA1).
Fred