Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

[Performance Issue] Select from MSEG

Former Member
0 Kudos
1,008

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.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Kudos
637

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

7 REPLIES 7
Read only

Former Member
0 Kudos
637

try to avoid corrosponding field command.you will get the difference.

Read only

Former Member
0 Kudos
638

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

Read only

Former Member
0 Kudos
637

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

Read only

kesavadas_thekkillath
Active Contributor
0 Kudos
637

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....

Read only

kesavadas_thekkillath
Active Contributor
0 Kudos
637

sorry, remove the for all entries from u r query and apply this

Read only

kesavadas_thekkillath
Active Contributor
0 Kudos
637

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.

Read only

kesavadas_thekkillath
Active Contributor
0 Kudos
637

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