Skip to Content
0
Former Member
Aug 01, 2005 at 11:45 AM

Performance problems selecting form vbak and vbap

228 Views

Hello,

I am try to select data from the vbak and vbap databasetables. The tables have more than a million of entries. I tried my best with two related selectstatements and the 'FOR All ENTRIES' syntax. The query takes more than 30 minutes. Is there a more efficient way than the following query, for example an inner join?. Tanks.

Regards, Lars.

-


FORM firstselect.

SELECT kvkorg kvtweg kspart kauart k~kunnr

kvsbed kaugru kvbeln kmandt

FROM VBAK AS k

INTO CORRESPONDING FIELDS OF TABLE t_outtab1

WHERE k~vkorg IN s_vkorg AND

k~vtweg IN s_vtweg AND

k~spart IN s_spart AND

k~auart IN s_auart AND

k~kunnr IN s_kunnr AND

k~vsbed IN s_vsbed AND

k~augru IN s_augru AND

k~vbeln IN s_vbeln.

ENDFORM.

FORM secondselect.

SELECT pposnr pvstel p~werks

pabgru pmatnr p~kwmeng

pzzurmeng pvrkme pmandt pvbeln

FROM VBAP AS p

INTO CORRESPONDING FIELDS OF TABLE t_outtab2

FOR ALL ENTRIES IN t_outtab1

WHERE

p~vstel IN s_vstel AND

p~werks IN s_werks AND

p~matnr IN s_matnr AND

p~abgru IN s_abgru AND

  • t_outtab1-mandt = p~mandt AND

p~vbeln = t_outtab1-vbeln.

ENDFORM.