11-08-2007 2:22 PM
Hello,
I have this code :
...........................................
SELECT emkey FROM okk00
INTO TABLE gt_ods_okk
WHERE eloekz = 'X'.
IF sy-subrc EQ 0.
loop on the resulting internal table
LOOP AT gt_ods_okk ASSIGNING <wa_ods_okk>.
OKP processing
CLEAR gt_ods_okp[] .
for each order -> select not deleted positions (REASON_REJ EQ '' )
SELECT * FROM okp00
INTO TABLE gt_ods_okp
WHERE emkey = <wa_ods_okk>-emkey
AND reason_rej = ' '.
...................................................................................................
The problem is that if I select records from a table and have in the where clause a field which is not part of the index of the table (eloekz in my case ) , I will read all the records of the table (sequential access). So I have to be sure that there is an adequate index for my select.
I have to leave the where condition, because I need the records with eloekz = 'X'.
How can I do this ?
Suggestion ? (I can't use cursor..so other option, please ).
Many thanks.
11-08-2007 2:39 PM
Table okk00 doesn't exist in our system. What release are you on?
How many records in this table?
Rob
11-08-2007 2:44 PM
It is not a system table.
I don't know... a few thousands....Why is this relevant?
11-08-2007 3:00 PM
Because if the table is small, then it just doesn't matter if you use an index. If you just do this SELECT once in the program, it might not be much of an issue.
Rob
11-08-2007 3:10 PM
No it shouldn't read the whole table if this table is not a cluster type, the sql "engine" will create a temporary index on the database server. (Else change database...)
What can make your program "heavy" in resource is the fact that you LOOP on the read records and then do a select one by one to read the secondary table.
You have done part of the job, checking sy-subrc after the first table read, better use a
SELECT FROM okp00 FOR ALL ENTRIES IN gt_ods_okk.
Regards