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

MSEG Table Performance Problem

Former Member
0 Likes
680

Hi Friends,

I have developed one report for Stock age analysis in which i m using MSEG table which is taking so much time when running in production server because of so many records.

this is the code.........

SELECT MBLNR MJAHR VGART BUDAT

FROM MKPF

INTO CORRESPONDING FIELDS OF TABLE IT_MKPF

WHERE VGART IN S_VGART

AND BUDAT IN S_DAT .

IF IT_MKPF[] IS NOT INITIAL.

SELECT MBLNR MATNR LGORT EBELN EBELP WERKS BWART HSDAT ERFMG LBKUM SHKZG DMBTR SALK3

FROM MSEG

INTO CORRESPONDING FIELDS OF TABLE IT_MSEG_TMP

FOR ALL ENTRIES IN IT_MKPF

WHERE MBLNR = IT_MKPF-MBLNR

AND MJAHR = IT_MKPF-MJAHR

AND MATNR IN S_MATNR

AND WERKS = P_WERKS

AND LGORT IN S_LGORT.

ENDIF.

or

IF IT_MARA[] IS NOT INITIAL.

SELECT MBLNR MATNR EBELN EBELP WERKS BWART HSDAT ERFMG

FROM MSEG

INTO CORRESPONDING FIELDS OF TABLE IT_MSEG

FOR ALL ENTRIES IN IT_MARA

WHERE MATNR = IT_MARA-MATNR

AND WERKS = P_WERKS

AND BWART = '101'.

ENDIF.

both code taking so much time........

4 REPLIES 4
Read only

Former Member
0 Likes
528

Hello,

Every thing is correct in your code i think MSEG table contain huge data but one thing is that you remove the

INTO CORRESPONDING FIELDS OF TABLE IT_MSEG_TMP

just keep INTO TABLE IT_MSEG_TMP atleast this will increase the performance before keep INTO TABLE IT_MSEG_TMP keep the fields in the order in the select statement just like internal table structure.

After fetching the data into the internal table sort the internal table

sort IT_MKPF by MBLNR MJAHR.

Read only

Former Member
0 Likes
528

Hi Amit ,

avoid using CORRESPONDING FIELDS OF TABLE IT_MSEG_TMP

plus there are indexes provide in MSEG table ..

u can try using ne of those ...

Regards

Renu

Read only

Former Member
0 Likes
528

Hi,

May be it is MKPF selection that is taking time when you Z_VGART and S_DAT is not entered in the selection screen.

I also dont see that you are using the MJAHR while selecting the MKPF (you can derive the year by lofrom S_DAT )

regards,

Advait

Read only

Former Member
0 Likes
528

hi amit,

try to avoid using the code INTO CORRESPONDING addition as much as possible

and check whether there are any indexes to use so access rate becomes much faster.

One more i would like to tell u is check from your reqiurement whether u can keep

material number mandatory