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: 

How to use the secondary index for bkpf table in abap-program

Former Member
0 Kudos

Sir,

           I have used Table :- BKPF in my program, The program is taking more than 10 minutes to get the output.

           I have used a non-key field (cpudt) , in where condition of open cursor statement to retrive data from bkpf.

           can u pls explain the process of  how to use the secondary index in abap-program to retrive the data faster.

Thanks & Regards.

Moderator message: please search for information before posting.

Message was edited by: Thomas Zloch

4 REPLIES 4

former_member184497
Participant
0 Kudos

This message was moderated.

raymond_giuseppi
Active Contributor
0 Kudos

First check BKPF~5 is active in your system (and for database like Oracle check if statitics are up-to-date) - NB: You must provide values for bukrs key field.

As a last solution, if you are not able to get the correct index determined by SQL optimizer, you can use %HINTS to force use of an index. Syntax is database dependant - see Note 129385 - Database hints in Open SQL to find note for your database.

Regards,

Raymond

former_member392866
Active Participant
0 Kudos

Satish,

steps:

1.Go to SE11

2.Give database table as BKPF and click on display.

3.Now click on Indexes button on right sight corner.

4.Now click on create button on popup

5.Now give the index id which is starts with Z  ex:- Z4 ...

6.Give fields what ever you are using non-key fields followed by keyfields (i.e,BUKRS,BELNRGJAHR).

  and save everything.

Rewards if helpful.

Thank you.

Regards,

BALAJI.

Former Member
0 Kudos

Hi

You can use the following code to select the index of your choice for table access:

SELECT * FROM <Table>

  %_HINTS ORACLE 'INDEX("<Table Name>" "<Table Name>~<Index Id>")'

For E.g.

SELECT * FROM MARA

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