08-30-2007 8:35 AM
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
08-30-2007 9:09 AM
Hi,
Avoid join and use for all entries instead of join, pass all the keys.
You can create index also.
regards,
Prashant
08-30-2007 8: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
08-30-2007 9:09 AM
Hi,
Avoid join and use for all entries instead of join, pass all the keys.
You can create index also.
regards,
Prashant
08-30-2007 9:22 AM
HI,
Create an index in MSEG containing MANDT and all the other fields. It will help.
Regards,
Mallick
08-30-2007 9: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