Skip to Content

Need to optimize times for VBRK--> VBAP query...

Hi all,

I need to access VBRK/VBAP data according to the invoice date, so I have written the following SQL statement:

  SELECT
  vbrk~zuonr
  vbrk~vbeln
  vbrk~belnr
  vbrk~fkdat
  vbrk~fksto
  vbrk~zzfechaegr
  vbrk~kunag
  kna1~name1
  kna1~name2
  vbrk~netwr
  vbrk~zzptofact
  vbap~vbeln
  vbap~posnr
  vbap~erdat
  vbap~abgru
  vbap~matnr
  vbap~arktx
  vbap~kwmeng
  vbap~netpr
  vbap~kzwi1
  vbap~kzwi2
  vbap~kzwi3
  vbap~kzwi4
  vbap~netwr
  vbap~shkzg
  vbap~prodh
  t179t~vtext
  vbap~kdmat
  vbap~zzfechacar
  vbap~zznamusuar
  vbap~zzhoracarga
  vbap~ktgrm
  vbap~zztipingr
  vbap~zzcodrol
  vbap~zzcodmedp
  vbap~zznroref
  INTO TABLE gt_alv
  FROM vbrk
  INNER JOIN vbak
  ON vbak~bstnk = vbrk~zuonr
  LEFT  JOIN kna1
  ON  kna1~kunnr = vbrk~kunag
  INNER JOIN vbap
  ON vbap~vbeln = vbak~vbeln
  INNER JOIN t179t
  ON  t179t~spras = sy-langu
  AND  t179t~prodh = vbap~prodh
  WHERE (w_info).


In this case, w_info is a dynamic selection clause that, if no additional selection criteria are specified, has the value
vbak~vbtyp = 'M' and vbak~fkdat>= s_date-low and vbak~fkdat <= s_date-high


My problem is that, sometimes, the number of records selected can be very high, and the statement takes too much time running.

A quick ST05 run seems to imply that all of the tables are being accessed by the proper indexes…

Does anybody have any ideas about how to improve/optimize this query?

Thanks in advance,

Luis

SQL
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

0 Answers