Application Development and Automation 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: 
Read only

Select query taking more time..

former_member192432
Participant
0 Likes
973

Hi friends ,

The below select queries are taking more time , in tried for secondary index but not found .

SELECT ebeln

ebelp

loekz

aedat

TXZ01

MATNR

werks

BEDNR

menge

meins

ELIKZ

KNTTP

LABNR

FROM ekpo INTO TABLE gt_ekpo_all

FOR ALL ENTRIES IN gt_ekko WHERE

ebeln EQ gt_ekko-ebeln " commenetd by chetan on 2009/11/13

and loekz = ' '

AND matnr IN matnr

AND werks IN werks

AND bednr IN bednr.

Internal table gt_ekko is having 277283 records.

SELECT OBJECTCLAS

OBJECTID

UDATE

TCODE

FROM cdhdr INTO TABLE gt_cdhdr2

FOR ALL ENTRIES IN gt_cdhdr

WHERE objectclas = 'EINKBELEG'

AND objectid = gt_cdhdr-objectid

AND tcode = 'ME28'.

Internal table gt_cdhdr is having 277283 records.

please can any one tell how to solve it .I tried writing non primary key outside the select statement by using delete technique then also both are taking more time .

Thanks & Regards

Chetan

10 REPLIES 10
Read only

Former Member
0 Likes
940

Hi,

Check the points below.

1. The selecting field from EKPO should be in the same order as in DATABSE EKPO.

2. If taking more time try to create a secondary index on ebeln loekz matnr werks bednr

regards,

NZR

Read only

0 Likes
940

Hi Nazeer ,

The fields are as per the order only , and i cant create secondary index as a BASIS people instruction .

Regards

chetan

Read only

0 Likes
940

Hi Chetan,

Use Inner Joins instead of For all entries and try

-manasi

Read only

Peranandam
Contributor
0 Likes
940

keep vbeln only in where clause and remove other fields from where clause. once you fetched record into internal table do deletion on internal table. dont create secondary index.

ex.

delete tabel gt_ekpo where matnr not in matnr or

werks not in werks o

r bednr not in bednr.

Read only

Former Member
0 Likes
940

Hi Chetan ,

You should use ST05(trace) to check which index is being accessed. As per my understanding , if their are no secondary index avaliable , then it will take primary index and hence you will not get a major performance improvement by creating secondary index.

Try to use some more fields in where clause , you can also make screen fields mandatory to reduce number of entries in internal table.

Hope this helps you.

Read only

Former Member
0 Likes
940

Hi ,

Make sure your Internal Table should not be intiial for that you have to use if statement before using FOR ALL ENTRIES.

Tri this it may work.

Regards,

Sudhakar Reddy Allam

Read only

Former Member
0 Likes
940

hi

in where clause add this also after ebeln

epelp ge l_ebelp

where ebelp is of type ebelp value is initial.

Read only

jayanthi_jayaraman
Active Contributor
0 Likes
940

Try

1. Before the forall entries, copy the contents of gt_ekko[] to gt_ekko_temp[] table and sort by ebeln and delete adjacent duplicates.

2. Use the temp table for for all entries. And in where use ebelp ne initial.

Read only

Former Member
0 Likes
940

Hi Chetan,

1. Select from EKPO :

A. First loop at internal table gt_ekpo and collect ebeln into a hash table.

B. Make use of that hash table while using for all entries.

C. As per u r requirement even u can check intial values of hash table before select statement.

2. Select from CDHDR:

A. First loop at Internal table gt_cdhdr and collect objectid into a hash table.

B. Use the hash table for all entries.

Read only

former_member192432
Participant
0 Likes
940

hi thanks for reply..