Skip to Content
0
May 07, 2013 at 03:56 AM

Select statement extremely slow when field dont have value

411 Views

Hi all,

Following is the select statement I use: If user enter a value for ARBPL in the select-options field, the selection process is very slow because the user entered value does not exist in database table. If there is ARBPL value, then the selection process is ok. How can I rectify this problem whenever there is no value in the database tables entered by user in the select options field. Thanks.

get process order main material
SELECT a~aufnr
a~werks
b~plnbez
b~gstrp
b~gltrp
c~wemng
d~bedid
e~objid
e~arbpl
* f~xloek
f~matkl

INTO CORRESPONDING FIELDS OF TABLE lt_process_order
FROM aufk AS a
INNER JOIN afko as b
ON b~aufnr = a~aufnr
INNER JOIN afpo AS c
ON c~aufnr = b~aufnr
INNER JOIN afvc AS d
on d~bedid = b~bedid
INNER JOIN crhd AS e
ON e~objid = d~arbid
INNER JOIN mara AS f
ON f~matnr = b~plnbez
WHERE a~werks IN s_plant
AND a~aufnr IN s_po
AND b~gstrp IN s_from
AND e~arbpl IN s_res
AND f~matkl LIKE 'PG%'
AND a~autyp = '40' "only take process order, as aufk also share with orders not related to production
AND e~verwe = '0008'. "only take resource related to production