Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

select stmt taking long time.

Hi,

This stmt is taking long time to execute. Is there any way, we can modify it to perform well.

SELECT kna1~NAME1

vbak~ERNAM

vbak~erdat

vbak~KUNNR

vbak~VBELN

vbak~AUART

FROM VBAK

INNER JOIN kna1 on kna1kunnr = VBAKKUNNR

INTO TABLE ITAB_VBAK

WHERE VBAK~ERDAT IN SERDAT

AND VBAK~AUART IN SAUART.

Thanks

Veni.

Tags:
replied

HI veni,

change your code, and use for all entries.

data: begin of itab_vbak occurs 0,
      vbeln
       erdat
       ERNAM
       erdat
       KUNNR
       AUART
kunnr
name1
      end of itab_vbak.
data: l_tabix type sy-tabix.
SELECT vbeln
       erdat
       ERNAM
       erdat
       KUNNR
       AUART
FROM VBAK
INTO TABLE ITAB_VBAK
WHERE ERDAT IN SERDAT
AND  AUART IN SAUART.
if sy-subrc = 0.
select kunnr
       name1
      from kna1
      into table it_kna1
      for all entries in itab_vbak
     where kunnr = itab_vbak-kunnr.
if sy-subrc = 0.
loop at itab_vbak.
l_tabix = sy-tabix.
read table it_kna1 with key kunnr = itab_vbak-kunnr.
if sy-subrc = 0.
itab_vbak-name1 = it_kna1-name1.
modify itab_vbak index l_tabix.
endif.
endloop.
endif.
endif.

regards

vijay

0 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question