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

index11

Former Member
0 Likes
745

hi experts,

thanq all

but how to use primary index and secondary indexes in select statment .shall we use both at same time in select staament .please explaine me with examples.

thanks in advance.

radhakrishna.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
628

Hi,

primary index will be used by default in all the Select statments, if you do not specify in INDEX with the select statment, then the primary index will taken by SAP automatically.

If the underlying database is ORACLE, then you can specify the secondary index to be used by the following statement:

SELECT * FROM SPFLI

%_HINTS ORACLE 'INDEX("SPFLI" "SPFLI~001")'

.......

ENDSELECT.

You can also check:

http://www.saptechnical.com/Tips/ABAP/SecondaryIndexes.htm

Regards

Sudheer

Regards

Sudheer

3 REPLIES 3
Read only

seshatalpasai_madala
Product and Topic Expert
Product and Topic Expert
0 Likes
628

Hi,

You cannot force the use of INDEX, its upto the Database Optimizer in the Workprocess to decide weather to use the INDEX or NOT.

BUT INDEX will be used when your SELECT query's WHERE CLAUSE has as many fields of INDEX as possible. Also you need to put the fields in the SAME ORDER as they appear in the INDEX.

So if your index is on FLD1 FLD2 and FLD3

then in your query use SELECT * FROM TAB WHERE FLD1 = and FLD2 = and FLD 3.

Regards,

Sesh

Read only

Former Member
0 Likes
629

Hi,

primary index will be used by default in all the Select statments, if you do not specify in INDEX with the select statment, then the primary index will taken by SAP automatically.

If the underlying database is ORACLE, then you can specify the secondary index to be used by the following statement:

SELECT * FROM SPFLI

%_HINTS ORACLE 'INDEX("SPFLI" "SPFLI~001")'

.......

ENDSELECT.

You can also check:

http://www.saptechnical.com/Tips/ABAP/SecondaryIndexes.htm

Regards

Sudheer

Regards

Sudheer

Read only

Former Member
0 Likes
628

Hi,

We can use both secondary index and primary index in a single select statement. First we need to use secondary index in where condition then we can use primary index after that non primary keys. if secondary index is not there we will use primary index directly.

Reward points if useful.

Thanks & Regards,

Vasudeva Rao