‎2008 Nov 28 10:37 AM
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
‎2008 Nov 28 10:45 AM
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
‎2008 Nov 28 10:44 AM
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
‎2008 Nov 28 10:45 AM
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
‎2008 Nov 28 10:50 AM
Thanx... For your immediate response...
The MSEG~M index is used in my query.. ...
Thanks and Regards,
Murugesh R
‎2008 Nov 28 10:54 AM
hi gurus...
Kindly Guide me ... if any alternate is there ?
Thanks & Regards,
Murugesh R
‎2008 Nov 28 2:28 PM
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 .
‎2008 Nov 29 4:27 AM
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
‎2008 Dec 01 1:10 PM
Dear Muragesh,
U can use READ statement with BINARY SEARCH.
check the internal table shoiuld not be initial.
Best Regards,
Flavya
‎2008 Dec 02 4:11 AM
Thanx Flavya...
My problem is above mentioned query is taking long time...
Any alternate to get material document No...
Regards,
Murugesh R
‎2008 Dec 02 7:40 AM
Hi ,
what are the fields u are using in the index MSEG~M ?
regards
Prabhu
‎2008 Dec 02 8:09 AM
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
‎2008 Dec 02 8:19 AM
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
‎2008 Dec 02 10:28 AM
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
‎2008 Dec 02 3:56 PM
a JOIN is not always the better way to retrieve records...........maybe you should try it with 2 selects
‎2008 Dec 23 9:45 AM
Thanx for all for your valuable guidelines..
Regards,
Murugesh R