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

select allentries

Former Member
0 Likes
511

hi experts,

  1. what is the use of select for all entries in an internal

table?

  1. when you are using 2 internal table in program, you have

decided to use for all entries statement to retrieve data

but unfortunately there are no records in the first internal

table. What will be the result? (2nd internal table contains

records).

thanks in advance.

4 REPLIES 4
Read only

Former Member
0 Likes
475

If the FOR ALL ENTRIES table is empty, the resulting table for the second select will contain all entries (that meet the other conditions of the WHERE).

Rob

Read only

Former Member
0 Likes
475

Hi,

1) FOR ALL ENTRIES can be used to retrive the data based on the values of an internal table..

EXAMPLE.

-


DATA: T_VBAK TYPE STANDARD TABLE OF VBAK.

DATA: T_VBAP TYPE STANDARD TABLE OF VBAP.

SELECT MANDT VBELN FROM VBAK

INTO TABLE T_VBAK

WHERE ERDAT = SY-DATUM.

IF NOT T_VBAK[] IS INITIAL.

SELECT MANDT VBELN POSNR

INTO TABLE T_VBAP

FROM VBAP

FOR ALL ENTRIES IN T_VBAK

WHERE VBELN = T_VBAK-VBELN.

ENDIF.

2) If there is no record in the first internal table then it will select all the records from the table..

In the above if you don't check for internal table value..then it will get all the records if the internal table T_VBAK is empty..

Thanks,

Naren

Read only

LucianoBentiveg
Active Contributor
0 Likes
475

If there are no records in the internal table used in for all entries, select statment get all entries in databse tqable.

Duplicates entries for result table are deleted.

Regards.

Read only

Former Member
0 Likes
475

Hi,

The WHERE clause of the SELECT statement has a special variant that allows you to derive conditions from the lines and columns of an internal table:

SELECT ... FOR ALL ENTRIES IN <itab> WHERE <cond> ...

<cond> may be formulated as described above. If you specify a field of the internal table <itab> as an operand in a condition, you address all lines of the internal table. The comparison is then performed for each line of the internal table. For each line, the system selects the lines from the database table that satisfy the condition. The result set of the SELECT statement is the union of the individual selections for each line of the internal table. Duplicate lines are automatically eliminated from the result set. If <itab> is empty, the addition FOR ALL ENTRIES is disregarded, and all entries are read.

The internal table <itab> must have a structured line type, and each field that occurs in the condition <cond> must be compatible with the column of the database with which it is compared. Do not use the operators LIKE, BETWEEN, and IN in comparisons using internal table fields. You may not use the ORDER BY clause in the same SELECT statement.

You can use the option FOR ALL ENTRIES to replace nested select loops by operations on internal tables. This can significantly improve the performance for large sets of selected data.

Examples

If there are no entries in the table then all the records are fetched.

Regards,

Vara