Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Urgent - Performance tuning

Former Member
0 Kudos
114

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

6 REPLIES 6

abdul_hakim
Active Contributor
0 Kudos
96

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

Former Member
0 Kudos
96

HI

instead of using inner join you can use Read statement in the loop.

that will increase the performance

timo_wendt
Explorer
0 Kudos
96

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]

former_member188685
Active Contributor
0 Kudos
96

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

christian_wohlfahrt
Active Contributor
0 Kudos
96

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

Former Member
0 Kudos
96

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.