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

Former Member
0 Kudos

hi exerts,

What is necessary step before writing the ‘for all entries’ statement? Give the syntax?

4 REPLIES 4

SG141
Active Participant
0 Kudos

Is good practice to check whether the internal table body(itab1) is not initial before doing select for all entries....

syntax :

if not itab1 is initial.
         select f1 f1 f3....
          from dbt1  into itab2 for all entries in itab1
          where <cond>.
endif.
f1 , f2 ,f3 - fields
dbt1 - data base table

0 Kudos

When using "Select.. For all Entries". The following 4 rules MUST be followed:

1 Check to make sure driver itab is not empty

2 Always SORT the itab (driver table) by keys. Specify all keys used in the Where clause

3 DELETE Adjacent Duplicates Comparing the keys that were sorted.

4 All Primary Key Fields must be in the Select List

if it helped, you can acknowledge the same by rewarding

0 Kudos

Hi,

a small but mighty addition:

You must SELECT all key fields of the FROM table even if you do not have them in the target area of the INTO CORRESPONDING FIELDS clause because the FOR ALL ENTRIES clause will cause a deletion of duplicates in the retrieved data.

And a small note: If the FOR ALL ENTRIES table is empty, the WHERE clause is ignored completely - even other conditions are ignored (!!).

Regards,

Clemens

messier31
Active Contributor
0 Kudos

Hi,

<b>Points to note are :-</b>

1. Duplicates are discarded from the result set.

2. If the internal table itab does not contain any entries, the system treats the statement as though there were no WHERE cond condition, and selects all records.

3. If you use FOR ALL ENTRIES IN itab, you cannot use ORDER BY f1 ... fn in the ORDER-BY clause.

<b>Sample Code :-</b>

SELECT * FROM SFLIGHT INTO WA_SFLIGHT

FOR ALL ENTRIES IN FTAB

WHERE CARRID = FTAB-CARRID AND

CONNID = FTAB-CONNID AND

FLDATE = '19950228'.

RATIO = WA_SFLIGHT-SEATSOCC / WA_SFLIGHT-SEATSMAX.

WRITE: / WA_SFLIGHT-CARRID, WA_SFLIGHT-CONNID, RATIO.

ENDSELECT.

Enjoy SAP.

Pankaj Singh.