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 while read MSEG

0 Likes
1,598

Hi Gurs,

Kindly guide me ....

I developed a report for Age wise stock analysis.. It is taking so much time when running in production server because of so many records in MSEG Table ...

Give the alternate if any ??

This is my code..

SELECT MSEGMBLNR MSEGMJAHR MSEGZEILE MSEGWERKS MSEGMATNR MSEGBWART MSEGMENGE MKPFBUDAT

INTO TABLE IT_TRANS

FROM MSEG AS MSEG JOIN MKPF AS MKPF

ON MSEGMANDT = MKPFMANDT AND

MSEGMBLNR = MKPFMBLNR AND

MSEGMJAHR = MKPFMJAHR

FOR ALL ENTRIES IN T_AGE_TMP

WHERE MSEG~MATNR EQ T_AGE_TMP-MATNR

AND MSEG~WERKS EQ PR_BWKEY

AND MSEG~LGORT IN SO_LGORT

AND MSEG~BWART IN BWART

AND MSEG~SHKZG EQ 'S'

AND MKPF~BUDAT IN BUDAT.

Thanks & Regards,

Murugesh R

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,425

Hi

U should check wich indexes are active your system for both tables MSEG and MKPF, probably your selection can't use any index.

Max

14 REPLIES 14
Read only

h_senden2
Active Contributor
0 Likes
1,425

MSEG is such a big table, you have to use the indexes (primary or secondary) to read it. If there is no index for your use you can create your own.

regards,

Hans

Read only

Former Member
0 Likes
1,426

Hi

U should check wich indexes are active your system for both tables MSEG and MKPF, probably your selection can't use any index.

Max

Read only

0 Likes
1,425

Thanx... For your immediate response...

The MSEG~M index is used in my query.. ...

Thanks and Regards,

Murugesh R

Read only

0 Likes
1,425

hi gurus...

Kindly Guide me ... if any alternate is there ?

Thanks & Regards,

Murugesh R

Read only

0 Likes
1,425

SELECT MSEGMBLNR MSEGMJAHR MSEGZEILE MSEGWERKS MSEGMATNR MSEGBWART MSEGMENGE MKPFBUDAT

INTO TABLE IT_TRANS

FROM MSEG AS MSEG JOIN MKPF AS MKPF

ON MSEGMANDT = MKPFMANDT AND

MSEGMBLNR = MKPFMBLNR AND

MSEGMJAHR = MKPFMJAHR

FOR ALL ENTRIES IN T_AGE_TMP

WHERE MSEG~MATNR EQ T_AGE_TMP-MATNR

AND MSEG~WERKS EQ PR_BWKEY

AND MSEG~LGORT IN SO_LGORT

AND MSEG~BWART IN BWART

AND MSEG~SHKZG EQ 'S'

AND MKPF~BUDAT IN BUDAT.

1.Before this above select,

Sort and delete the for all entries table by matnr .

You should pass only unique records to it.

If required,have a help table .

Read only

0 Likes
1,425

Thanx Raj....

Before the select statement ... I check the for all entries table is not initial and Sort the table by matnr and delete the adjacent duplicates ...

Performance issues for material type SCIN only it have lot of entries...

What is help table? Kindly Explain...

Thanks & Regards,

Murugesh R

Read only

Former Member
0 Likes
1,425

Dear Muragesh,

U can use READ statement with BINARY SEARCH.

check the internal table shoiuld not be initial.

Best Regards,

Flavya

Read only

0 Likes
1,425

Thanx Flavya...

My problem is above mentioned query is taking long time...

Any alternate to get material document No...

Regards,

Murugesh R

Read only

Former Member
0 Likes
1,425

Hi ,

what are the fields u are using in the index MSEG~M ?

regards

Prabhu

Read only

0 Likes
1,425

Dear Prabhu,

Index MSEG M ( its delivered by SAP) has below fields,

MANDT Client

MATNR Material Number

WERKS Plant

LGORT Storage location

BWART Movement Type (Inventory Management)

SOBKZ Special Stock Indicator

Regards,

Murugesh R

Read only

0 Likes
1,425

With whatever you had mentioned above, I don't think of any other way of improving performance.

At most, you can make sure user enters LGORT on screen, if user agrees, you may make LGORT and BWART as mandatory field.

Also make sure, you index M is active at database level. If it is not active at databse level, you will get warning message displayed while viewing index.

Regards,

Mohaiyuddin

Read only

Former Member
0 Likes
1,425

Hi,

You can reduce DB time by removing FOR ALL ENTRIES clause in select query ,and use Ranges to delete IT_TRANS entries based on MATNR i.e. use a delete statement

Read only

Former Member
0 Likes
1,425

a JOIN is not always the better way to retrieve records...........maybe you should try it with 2 selects

Read only

0 Likes
1,425

Thanx for all for your valuable guidelines..

Regards,

Murugesh R