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

Read mseg

Hi all

i have program reading mseg,when the system reas mseg it's getting very slow,please help me ,pleas find the code follows

SELECT AWERKS ASAKTO AKOSTL AMENGE ADMBTR AMATNR ABWART BMAKTX

CTXT50 DBUDAT DMBLNR EZEINR INTO

CORRESPONDING FIELDS OF TABLE IT_ITAB

FROM MSEG AS A INNER JOIN MAKT AS B ON AMATNR = BMATNR

INNER JOIN GL_ACCT_CC_TEXT AS C ON ASAKTO = CSAKNR

INNER JOIN MKPF AS D ON AMBLNR = DMBLNR

INNER JOIN MARA AS E ON AMATNR = EMATNR

WHERE D~BUDAT IN PR_DATE AND

A~WERKS = PR_WERKS AND

A~SAKTO IN PR_SAKTO and

( aBWART ='201' or aBWART ='202' ).

thanks

kanishka

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Best Answer
    Posted on Aug 30, 2007 at 08:09 AM

    Hi,

    Avoid join and use for all entries instead of join, pass all the keys.

    You can create index also.

    regards,

    Prashant

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 30, 2007 at 07:57 AM

    Hi

    avoid writing joins

    SELECT AWERKS ASAKTO AKOSTL AMENGE ADMBTR AMATNR ABWART BMAKTX

    CTXT50 DBUDAT DMBLNR EZEINR INTO

    CORRESPONDING FIELDS OF TABLE IT_ITAB

    FROM MSEG AS A INNER JOIN MAKT AS B ON AMATNR = BMATNR

    INNER JOIN GL_ACCT_CC_TEXT AS C ON ASAKTO = CSAKNR

    INNER JOIN MKPF AS D ON AMBLNR = DMBLNR

    INNER JOIN MARA AS E ON AMATNR = EMATNR

    WHERE D~BUDAT IN PR_DATE AND

    A~WERKS = PR_WERKS AND

    A~SAKTO IN PR_SAKTO and

    ( aBWART ='201' or aBWART ='202' ).

    instead of this go for

    <b>FOR ALL ENTRIES</b>

    then your program will get good results

    ... [FOR ALL ENTRIES IN itab] WHERE sql_cond ... .

    Effect:

    The addition WHERE restricts the number of lines included in the result set by the statement SELECT, by using a logical expression sql_cond. The logical expression compares the content of columns in the database with the content of ABAP data objects, or with the content of other columns. You can use the optional addition FOR ALL ENTRIES to compare the content of a column in the database with a component with all lines of a structured internal table itab.

    The logical expression sql_cond is either true, false, or unknown. The expression is unknown if one of the columns involved in the database contains a null value and is evaluated with another comparison as IS NULL. A line is only included in the resulting set if the logical expression is true.

    Except for columns of type STRING or RAWSTRING, all columns of the database tables or views listed after FROM can be evaluated after the WHERE condition. The columns do not necessarily have to be a part of the resulting set.

    Notes:

    The client identifier cannot be queried in the WHERE condition, if automatic client handling is not deactivated using the addition CLIENT SPECIFIED after FROM.

    The WHERE condition of the SELECT statement described here includes the WHERE conditions of the Open SQL statements DELETE, OPEN CURSOR, and UPDATE.

    The logical expressions of the WHERE condition can also all be used after the addition HAVING, and sometimes in the ON condition of a Join expression after the addition FROM.

    If the database table is accessed with generic SAP buffering, the buffered area must be fully specified in the WHERE condition, otherwise buffering is not carried out.

    REWARD IF USEFULL

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 30, 2007 at 08:22 AM

    HI,

    Create an index in MSEG containing MANDT and all the other fields. It will help.

    Regards,

    Mallick

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 30, 2007 at 08:29 AM

    Hi,

    dont use this much of joins statement and u r using feilds in where condition r not key-fields in any table.

    Before use For all entries statement try to give input in where condition are ky-fields like mblnr , mjahr, matnr etc... then it fetch the data very fast.

    Reward with points if useful.

    Regards,

    Vijay

    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.