12-11-2008 7:47 PM
Hi Friends,
I am facing performance issue in this select statement.
Can you suggest me alternate code to increase the performance of the below statement.
*SELECT bukrs belnr gjahr projk buzei*
*bschl shkzg mwskz dmbtr*
*mwsts lifnr menge*
*FROM bseg*
*INTO TABLE i_bseg_a*
*WHERE belnr LIKE '24%'*
*OR belnr LIKE '004%'*
*AND bukrs EQ x_bukrs-bukrs*
*AND gjahr EQ w_yr_low.*
Regards
Mahesh KUmar
12-11-2008 7:55 PM
Instead of like statement try to use >= = '24000000' <= '239999999' etc..
12-11-2008 8:08 PM
Hi,
Also in addition to the above suggestion, the order in which you have specified the fields in the where clause is wrong.
Give BUKRS, BELNR and then GJAHR. Also add some more criteria's from the BKPF table like document creation date, posting date etc. Otherwise you will end up selecting all the documents present in the BSEG table startiing with 24.
regards,
Advait
12-11-2008 8:33 PM
The order of the WHERE makes no difference.
But in this case, missing parenthesis is the problem. You are picking up all documents that start with '24'.
Rob
Edited by: Rob Burbank on Dec 12, 2008 9:13 AM
12-11-2008 8:32 PM
Hi,
Give this a try:
DATA: r_belnr TYPE TABLE OF selopt.
FIELD-SYMBOLS: <fs_belnr> TYPE selopt.
APPEND INITIAL LINE TO r_belnr ASSIGNING <fs_belnr>.
<fs_belnr>-sign = 'I'.
<fs_belnr>-option = 'CP'.
<fs_belnr>-low = '24*'.
APPEND INITIAL LINE TO r_belnr ASSIGNING <fs_belnr>.
<fs_belnr>-sign = 'I'.
<fs_belnr>-option = 'CP'.
<fs_belnr>-low = '004*'.
SELECT bukrs belnr gjahr buzei projk buzei
bschl shkzg mwskz dmbtr
mwsts lifnr menge
FROM bseg
INTO TABLE i_bseg_a
WHERE bukrs = x_bukrs-bukrs
AND belnr IN r_belnr
AND gjahr = w_yr_low.
IF sy-subrc <> 0.
"Error handling
ENDIF.
Regards,
Jamie
Edited by: James Gaddis on Dec 11, 2008 3:33 PM
12-12-2008 4:05 AM
Hi,
make ranges fro beln...
Use always, key fields,
Thanks,
Krishna..
12-12-2008 3:31 PM
Hi,
the fields you are retrieving exists also in tables : BSIS, BSID, BSIK.
please try to use other table like BSIS instead of BSEG which is a cluster table.
This will improve performance.
Thanks and regards,
Dev.