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

Problem with INDEX

Former Member
0 Likes
1,539

When the following SELECT SENTENCE is executed:

SELECT DISTINCT bukrs vbeln kunag fkart waerk fkdat

FROM vbrk CLIENT SPECIFIED

INTO TABLE ti_factura

WHERE mandt = '400' and fkart IN p_fkart

AND fkdat between p_budat1 and p_budat2

it alway performs a sequential search dispite we've created and activated an index with these fields:

MANDT

FKART

FKDAT

What can I do to get the SELECT use the index ?

Regards,

7 REPLIES 7
Read only

Former Member
0 Likes
1,486

Hi,

1)

Make sure you have value in P_FKART

2)

To force index to a sql use the following..

Example if you have created index name as Z01...Changes marked in bold..

SELECT DISTINCT bukrs vbeln kunag fkart waerk fkdat

FROM vbrk CLIENT SPECIFIED

INTO TABLE ti_factura

WHERE mandt = '400' and fkart IN p_fkart

AND fkdat between p_budat1 and p_budat2

<b>%_HINTS oracle 'INDEX("&TABLE&" "VBRK~Z01" "VBRK^Z01")'</b>

Thanks,

Naren

Read only

Former Member
0 Likes
1,486

HI,

You need to write the secondary indes like

SELECT * FROM spfli

<b>%_HINTS ORACLE 'INDEX("SPFLI" "SPFLI~001")'</b>

...

ENDSELECT.

<b>SPFLI~001 is the index</b>

Read only

dairolozano
Contributor
0 Likes
1,486

This message was moderated.

Read only

Rodrigo-Giner
Active Contributor
0 Likes
1,486

Pls check that the index really exist in the DB.

In the SE11 when you go the the indexes choose it and make sure that the index exist in the DB

"Index VBRK~ZFA exists in database system ORACLE"

The index being activated is not the same that exists in the DB. You can have an index activated that says that it doesn't exist in the DB.

So make sure it rlly exist.

Regards

Read only

0 Likes
1,486

Hello Leonardo,

1) If you want to hit your index on SELECT statement exactly, specify index name like %_HINTS ORACLE 'INDEX("KNA1" "KNA1~001")'.

SELECT KUNNR

    FROM KNA1

     INTO TABLE lt_kunnr

     %_HINTS ORACLE 'INDEX("KNA1" "KNA1~001")'..

2) Even your index is not hit on your select exactly,ask your basis consultants run DBSTAT on table. It adjust index and table.

Thanks,Sateesh K

Read only

former_member184158
Active Contributor
0 Likes
1,486

HI

You can use an index with the statement

    %_HINTS oracle 'INDEX("<index name>")'

example:

SELECT DISTINCT bukrs vbeln kunag fkart waerk fkdat

      FROM vbrk CLIENT SPECIFIED

      INTO TABLE ti_factura

           WHERE mandt = '400' and fkart IN p_fkart

                 AND fkdat between p_budat1 and p_budat2

                         %_HINTS oracle 'INDEX("Z01")'.

look to this document, may help you.

Performance Improvement using Indexes and ABAP Hints

http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/50509a26-8186-2d10-bca9-dc1284e24...

Regards

Ibrahim

Read only

kabil_g
Active Participant
0 Likes
1,486

This message was moderated.