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: 

For All Entries Primary Key?

Former Member
0 Kudos

Hi Guys,

I am having a doubt. when we are using For all entries in a select statement b/w Db table and Internal Table does we need to use only Primary key in Where condition ? can anybody tell in where condition i mean we can use any field or only Primary and Foreign keys?

for ex SELECT *

INTO TABLE lt_TJ30T

FROM TJ30T

FOR ALL ENTRIES IN lt_JSTO

WHERE STSMA EQ lt_JSTO-STSMA.

Very Urgent.

Thanks,

Gopi.

3 REPLIES 3

Former Member
0 Kudos

Hi,

No Gopi , there is no rule that we must use only primary key in the where clause.

But using the fields of the primary key in the where clause makes the select statement work fast because of the primary index.

Regards,

Madhusudhan

0 Kudos

Hi Madhusudhan,

Can u tell me how to find relation in Project Support b/w tables ? I want to find the relation(Primary Foreign key relation ship) b/w JSTO ,PROJ ,JEST ,TJ02T , TJ30T and TJ30 tables? Can u plz help me regarding this.

Thanks,

Gopi.

Former Member
0 Kudos

HI,

we use for all entries to improve the perfomance of data extraction. how can we reading the data from data base table fastly, by using primary or secondary indexes only. so while working with FOR ALL ENTRIES use only primary or secondary key values only.

Before using for all entries, try to sort internal table.

After that delete duplicate entries from internal table.

In select for all entries use as much as key fields in a selection table.

The for all entries creates a where clause, where all the entries in the driver table are combined with OR. If the number of entries in the driver table is larger than rsdb/max_blocking_factor, several similar SQL statements are executed to limit the length of the WHERE clause.

The plus

Large amount of data

Mixing processing and reading of data

Fast internal reprocessing of data

Fast

The Minus

Difficult to program/understand

Memory could be critical (use FREE or PACKAGE size)

Some steps that might make FOR ALL ENTRIES more efficient:

Removing duplicates from the driver table

Sorting the driver table

If possible, convert the data in the driver table to ranges so a BETWEEN statement is used instead of and OR statement:

FOR ALL ENTRIES IN i_tab

WHERE mykey >= i_tab-low and

mykey <= i_tab-high.

regards,

Ashok Reddy