2007 Aug 30 12:52 PM
Hi All,
An Internal table has no records. When i use Select for all entries for this internal table, what is the result i get?
Thanks,
Chakradhar
2007 Aug 30 3:41 PM
And the voting so far is:
ZERO entries: 5
EVERYTHING in Table: 4
So if we were going by popular vote, Zero would be the answer.
SAP Documentation says:
If the internal table itab is empty, the whole WHERE statement is ignored and<b> all lines in the database</b> are put in the resulting set.
So looks like those who voted for ZERO miss out this time.
Sorry
Andrew
Hi All,
An Internal table has no records. When i use Select for all entries for this internal table, what is the result i get?
Thanks,
Chakradhar
2007 Aug 30 12:57 PM
2007 Aug 30 12:58 PM
2007 Aug 30 1:01 PM
Hi
in the case of for all entries if for that selectin if there is no data availabale then it will display all the records available in that table
to avoid this sitvation
write like this
<b>select * from mara into table itab1 where condition
if not itab1[] is initial.
select * from marc into table itab2 for all entries in itab1 where condition</b>
in the above condition it will show 0 records
<b><REMOVED BY MODERATOR></b>
Message was edited by:
Alvaro Tejada Galindo
2007 Aug 30 1:01 PM
Hi Chakradhar,
You will get all records from the table.
If IT_VBAK has no record and you are using this table for selecting data from VBAP for all entries of IT_VBAK. It will fetch all records from VBAP
so best practice is use
If not it_vbak[] is inital.
--> write your for all entries select statement here
endif.
<b><REMOVED BY MODERATOR></b>
Thanks
Vishwanath Purohit
Message was edited by:
Alvaro Tejada Galindo
2007 Aug 30 1:03 PM
i think nothing will come
u have to place not initial condition
2007 Aug 30 1:07 PM
HI CHAKRA,
u wont get any output.
because for all entries will give u value according to the entries in your first table.
when u dont have any value in your first table for all entries cannot compare with any table.
that is the only reason we check for the INITIAL condition from second table.
<b><REMOVED BY MODERATOR></b>
Message was edited by:
Alvaro Tejada Galindo
2007 Aug 30 1:23 PM
hi,
If it happen so, then u will get all entries from DB Table which obviously wrong.
so first check if it[] is not initial.
Message was edited by:
Dhwani shah
2007 Aug 30 1:26 PM
<b>Don't ever make a select for all entries in itab if you haven't checked your itab before !!!</b>
Otherwise you'll fetch all the entries, I'll let you imagine the result in a Productive system.
So, the winner is.
If not itab[] is initial.
select * from mara
into corresponding fields of tabel itab_mara
for all entries in table itab
where matnr = itab-matnr.
endif.
2007 Aug 30 2:00 PM
hi,
actually all entries compares the entries with which u are going to select and creates the entries .
if no entries are there then it will show only 0.
2007 Aug 30 3:41 PM
And the voting so far is:
ZERO entries: 5
EVERYTHING in Table: 4
So if we were going by popular vote, Zero would be the answer.
SAP Documentation says:
If the internal table itab is empty, the whole WHERE statement is ignored and<b> all lines in the database</b> are put in the resulting set.
So looks like those who voted for ZERO miss out this time.
Sorry
Andrew
2007 Aug 30 4:52 PM
2007 Sep 25 5:06 PM
2007 Sep 25 5:16 PM
2007 Sep 25 6:49 PM
Hi,
the FOR ALL ENTRIES CLAUSE is very well documented. Type SELECT and press F1 in ABAP editor.
"If the internal table itab is empty, the whole WHERE statement is ignored and all lines in the database are put in the resulting set."
This is what some people here already said. But it is important because some guys believe that with an empty FOR ALL ENTRIES table any additional conditions (i.e. AND MTART = 'Z700') would be checked.
This is not the case (shout!).
Another pitfall (cost me a day or more!) is if you select only the fields you need for processing, you might not get all records. I tried to calculate an open item sum using for all entries and wondered why the result was not alwys correct.
Another note in the help:
"With duplicated rows in the resulting set, the addition FOR ALL ENTRIES has the same effect as if addition DISTINCT were specified in the definition of the selection quantity. Unlike DISTINCT, the rows are not deleted from the database system but are deleted on the application server from the resulting set. "
Not easy to understand. But it means that the resulting table has no duplicate entries. In my case, I collected customer no. and amount from BSEG. All items with identical customer number and open amount apperared only once.
The solution is that you have to select all key fields of the table you select from. If you use INTO CORRESPONDING FIELDS OF TABLE you do not need the fields in the resulting area, you will get all records anyway.
Regards,
Clemens
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |