2007 Jul 25 6:45 AM
Hi experts,
Need your help on how to improve the performance in the select from MSEG, it takes about 30 minutes to just finish the select. Thanks!
SELECT mblnr
mjahr
zeile
bwart
matnr
werks
lgort
charg
shkzg
menge
ummat
lgpla
FROM mseg
INTO CORRESPONDING FIELDS OF TABLE i_mseg2
FOR ALL ENTRIES IN i_likp
WHERE bwart IN ('601','602','653','654')
AND matnr IN s_matnr
AND werks IN s_werks
AND lgort IN s_sloc
AND lgpla EQ i_likp-vbeln.
2007 Jul 25 6:48 AM
Hi,
an important field for MSEG is the year.
MJAHR
You should put it in your select. In best case use it only with 1 year and not as an intervall.
Regards
Nicole
2007 Jul 25 6:47 AM
try to avoid corrosponding field command.you will get the difference.
2007 Jul 25 6:48 AM
Hi,
an important field for MSEG is the year.
MJAHR
You should put it in your select. In best case use it only with 1 year and not as an intervall.
Regards
Nicole
2007 Jul 25 6:59 AM
Hi,
Try to include all the key fields in ur selection criteria for this query.
The primary key fields of MSEG table is MBLNR, MJAHR, ZEILE.
But none of the key fields or included in ur where condition. This will definitely impact in performance
2007 Jul 25 7:14 AM
store all the vbeln to ranges.
ranges:r_vbeln for i_likp-vbeln.
r_vbeln-option = 'EQ'.
r_vbeln-sign = 'I'.
loop at i_likp.
r_vbeln-low = i_likp-vbeln.
append r_vbeln.
endloop.
sort r_vbeln ascending
delete adjacent duplicates from r_vbeln.
then modify the fetch as below.
donot use a loop to fetch data from mseg.
SELECT mblnr mjahr zeile bwart matnr werks lgort charg shkzg menge ummat lgpla
FROM mseg client specified INTO CORRESPONDING FIELDS OF TABLE i_mseg2
FOR ALL ENTRIES IN i_likp
where mandt = sy-mandt
and (bwart = '601' or bwart = '602' or bwart = '653' or bwart = '654' )
AND matnr IN s_matnr
AND werks IN s_werks
AND lgort IN s_sloc
AND lgpla in r_vbeln.
there is another table where u can get this data...i,ll let u know shortly...
try with this if useful
reward points....
2007 Jul 25 7:16 AM
sorry, remove the for all entries from u r query and apply this
2007 Jul 25 7:20 AM
if any where u can apply the date range it will be useful...
get the mblnr from mkpf for the date range and pass in mseg fetch.
2007 Jul 25 7:26 AM
there is one more table where u can get related data of mseg
S225
check it.......
from there u can get the data related to mseg and its fast