2006 Jan 31 7:46 AM
The following code takes more execution time..How can we reduce the execution time through performance tuning..
SELECT DISTINCT bebeln AS bktxt bebelp amblnr avgart bbwart bmatnr bwerks blifnr bmenge bebeln b~erfmg
INTO CORRESPONDING FIELDS OF TABLE it_mseg
FROM mkpf AS a INNER JOIN mseg AS b ON bmblnr = amblnr
FOR ALL ENTRIES IN it_ekpo
WHERE
bebeln = it_ekpo-ebeln AND bebelp = it_ekpo-ebelp AND b~matnr = it_ekpo-matnr
2006 Jan 31 7:51 AM
Hi
Remove the INTO CORRESPONDING addition,define an itab with the required field and use INTO TABLE addition.Make use of index while comparing.
Abdul
2006 Jan 31 7:53 AM
HI
instead of using inner join you can use Read statement in the loop.
that will increase the performance
2006 Jan 31 7:53 AM
When you use SELECT FOR ALL ENTRIES to compare more than one field of the internal table with DB-fields the database will select the data with UNION ALL-Statements. You can see this when you use the SQL-trace in the transaction ST05.
In addition maybe this WebLog can help you:
https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/2986 [original link is broken] [original link is broken] [original link is broken] [original link is broken] [original link is broken] [original link is broken] [original link is broken] [original link is broken]
2006 Jan 31 7:54 AM
Hi ,
try to remove the into corresponding ,
and declare the it_mseg in the order of your fields.
SELECT
DISTINCT b~ebeln AS bktxt
b~ebelp
a~mblnr
a~vgart
b~bwart
b~matnr
b~werks
b~lifnr
b~menge
b~ebeln
b~erfmg
INTO TABLE it_mseg
FROM mkpf AS a INNER JOIN mseg AS b ON b~mblnr = a~mblnr
FOR ALL ENTRIES IN it_ekpo
WHERE b~ebeln = it_ekpo-ebeln
AND b~ebelp = it_ekpo-ebelp
AND b~matnr = it_ekpo-matnr
2006 Jan 31 8:09 AM
Hi!
Either you go for index M of table MSEG.
Then specifiy in addition
b~MATNR eq it_ekpo-matnr
b~WERKS eq it_ekpo-werks
b~LGORT eq it_ekpo-lgort
b~BWART eq '101'
b~SOBKZ eq space
b~ebeln eq it_ekpo-ebeln
b~ebelp eq it_ekpo-ebelp.
Check, if movement type and special stock type are correct in your case. Maybe you need multiple entries, try if this can still speed up the select.
Or you go for document index EKBE.
Start selection the POs. Then select EKBE for all entries with VGABE = '1'. Then go for MKPF/MSEG with primary key. Every table starting from EKBE will have a (partial) primary key access, has to be pretty fast.
Regards,
Christian
2006 Jan 31 8:22 AM
Hello Siju,
For the query which you have written, following are my suggestions.
Create a view of MKPF/MSEG. This will be much effective than having an join as database takes care of the performance.