‎2006 Dec 07 4:59 PM
hi experts,
what is the use of select for all entries in an internal
table?
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.
‎2006 Dec 07 5:01 PM
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
‎2006 Dec 07 5:02 PM
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
‎2006 Dec 07 5:11 PM
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.
‎2006 Dec 07 5:11 PM
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