‎2008 Nov 10 5:15 AM
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........
‎2008 Nov 10 5:23 AM
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.
‎2008 Nov 10 5:39 AM
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
‎2008 Nov 10 8:58 AM
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
‎2008 Nov 10 9:37 AM
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