Skip to Content
author's profile photo Former Member
Former Member

MSEG select performance problem - Please help me (URGERNT)

I have the following SELECT stmt which is taking more time to execute......Kindly help me how to improve performance ...

YOUR HELP IS HIGHLY APPRECIATED....

SELECT a~mblnr

a~matnr

a~werks

a~charg

a~lifnr

a~bualt

a~erfmg

a~ebeln

a~ebelp

b~budat

INTO CORRESPONDING FIELDS OF TABLE it_mseg_mkpf

FROM mseg AS a INNER JOIN mkpf AS b

ON amblnr EQ bmblnr

WHERE a~matnr IN s_matnr

AND a~werks IN s_werks

AND a~lifnr IN s_lifnr

AND a~bwart EQ p_bwart

AND ( aebeln NE ' ' AND aebeln IN s_ebeln )

AND b~budat IN s_budat.

IF NOT it_mseg_mkpf IS INITIAL.

SELECT matnr bismt zzshelf_life FROM mara INTO TABLE it_mara

* FOR ALL ENTRIES IN it_mseg_mkpf*

* WHERE matnr = it_mseg_mkpf-matnr.*

ENDIF.

IF NOT it_mara IS INITIAL.

SELECT matnr maktx FROM makt INTO TABLE it_makt

* FOR ALL ENTRIES IN it_mara*

* WHERE matnr = it_mara-matnr.* ENDIF.

Thanks in advance,

Regards,

Add a comment
10|10000 characters needed characters exceeded

Related questions

4 Answers

  • Posted on Jan 23, 2008 at 12:07 PM

    Not equal is always a problem on the index, it does tell hat you want, but what you don't,

    it can not support an index-search

    Here the NE does not help

    AND ( aebeln NE ' ' AND aebeln IN s_ebeln )

    Try two branches for the whole select the one where s_ebeln is NOT initial,

    there you write

    AND a~ebeln IN s_ebeln

    the other branch where s_ebeln is initial, is hopefully less important

    AND a~ebeln NE ' '

    Siegfried

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 23, 2008 at 12:23 PM

    Join between MSEG and MKPF : Add the MJAHR field in join condition to give full key of table.

    ON amblnr EQ bmblnr AND amjahr EQ bmjahr

    The not-equal test also generates performance problems, try to adjust the s_ebeln to insure that initial value is not selected (if empty use a dummy range like 00000000-999999999)

    Regards

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 24, 2008 at 10:34 AM

    Hi Sam,

    Try this.

    SELECT a~mblnr

    a~matnr

    a~werks

    a~charg

    a~lifnr

    a~bualt

    a~erfmg

    a~ebeln

    a~ebelp

    b~budat

    INTO CORRESPONDING FIELDS OF TABLE it_mseg_mkpf

    FROM mkpf AS b INNER JOIN mseg AS a (although result will be same by reversing this join it's better to keep header on left of the join)

    ON amblnr EQ bmblnr and amjahr EQ bmjahr

    WHERE a~matnr IN s_matnr

    AND a~werks IN s_werks

    AND a~lifnr IN s_lifnr

    AND a~bwart EQ p_bwart

    AND ( aebeln NE ' ' AND aebeln IN s_ebeln )

    AND b~budat IN s_budat.

    (if possible, give mjahr in you selection screen and specify in where condition)

    IF NOT it_mseg_mkpf [ ] IS INITIAL. (previous condition will check header line only)

    SELECT matnr bismt zzshelf_life FROM mara INTO TABLE it_mara

    FOR ALL ENTRIES IN it_mseg_mkpf

    WHERE matnr = it_mseg_mkpf-matnr

    ENDIF.

    IF NOT it_mara[ ]

    IS INITIAL.

    SELECT matnr maktx FROM makt INTO TABLE it_makt

    FOR ALL ENTRIES IN it_mara

    WHERE matnr = it_mara-matnr.

    ENDIF.

    Regards,

    Mohaiyuddin

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 30, 2008 at 01:08 AM

    Hi Sam,

    1) Avoid select into corresponding fields and use select into table.

    2) Check the order of fields in the where clause.

    With Regards,

    Gandhi Subramani

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.