11-14-2006 1:11 PM
In select all entries statement , if empty internal table is there then what is the result.
11-14-2006 1:14 PM
it will fetch all the data from second table irrespective of for all entrie table where condition
You can only use FOR ALL ENTRIES IN ...WHERE ...in a SELECT statement.
SELECT ... FOR ALL ENTRIES IN itab WHERE cond returns the union of the solution sets of all SELECT
statements that would result if you wrote a separate statement for each line of the internal table replacing the symbol
itab-f with the corresponding value of component f in the WHERE condition.Duplicates are discarded from the result
set. 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 (in the current client).
for example:
SELECT * FROM sflight INTO wa_sflight
FOR ALL ENTRIES IN ftab
WHERE CARRID = ftab-carrid AND
CONNID = ftab-connid AND
fldate = '20010228'.
this condition, return all entries of the sflight
Message was edited by:
Raghavendra L
11-14-2006 1:14 PM
11-14-2006 1:16 PM
<b>All records will be fetched.</b>
To avoid that u have to use
<b>If itab[] is not initial.
select.....for all entries in itab.
endif.
Regs
Manas Ranjan Panda</b>
Message was edited by:
MANAS PANDA
11-14-2006 1:20 PM
Select field1 field2
from table1
into table i_tab
for all entries in itab2
where field1 = itab2-field1.
If the internal table used in for all entries is empty, the select will fetch all the records from table1 depending on the other where conditions...
If your program is dependant on itab2, then you might consider stopping the program execution.
if not itab2[] is initial.
Select field1 field2
from table1
into table i_tab
for all entries in itab2
where field1 = itab2-field1.
else.
stop. (or exit).
endif.
11-14-2006 1:48 PM
Hi,
This is definitely wrong!
If the internal table used with FOR ALL ENTRIES IN is empty/initial, the whole WHERE CLAUSE is ignored - all data are feched from database.
That means even id you have other conditions in the WHERE CLAUSE, they are ignored as well.
Please: Befor asking such questions, check the SAP online help available in the ABAP editor:
F1 on SELECT
WHERE clause
2. ... FOR ALL ENTRIES IN itab WHERE cond
..."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 (in the current client). "
It is a clear advanted if you can read
Regards,
Clemens
11-14-2006 1:28 PM
In Select with for all entries , the driver table should not be empty..
Because if it is empty , then the whole idea of For all entries is lost, as the
Select goes for full Table Scan (data base table).
Thats why we put the select with for all entries in IF -ENDIF block,
and in IF we check , that the driver table is not empty:
as
IF NOT ts_driver[] IS INITIAL.
SELECT
FROM
INTO
FOR ALL ENTRIES IN ts_driver
WHERE xyz EQ ts_driver-xyz.
ENDIF.
If not clear do let me know (if clear , give points !).
Cheers
Abhishek
11-14-2006 1:32 PM
Hi,
In such case where we are using select for all entries and internal table is blank, then our statement will behave like ":SELCT *.....":.It will select all records.
thanks,
Rajesh
11-14-2006 1:46 PM
Hi
Its the same thing as having an empty range in where condition. Select all the records without validation.
Thanks
Anirban M.
11-14-2006 1:50 PM
SAP online Docu:
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 (in the current client).
Regards,
Clemens
07-30-2007 10:27 PM
As a matter of interest, even if the internal table has entries, but has no result for the selection, it returns all entries in the table.....Just something I discovered to my regret recently