2006 Jun 15 5:12 PM
I have this piece of code:
select bukrs
hkont
belnr
waers
shkzg
wrbtr
prctr
into corresponding fields of table t_bsis
from bsis
for all entries in t_bukrs_rbeln
where bukrs eq t_bukrs_rbeln-bukrs
and zuonr eq p_sys
and gjahr eq p_gjahr.
When the table t_bukrs_rbeln has items, the select is correct but, I noticed that, when the table t_bukrs_rbeln is empty, then the select brings ALL the entries from the table bsis.
I can nest this code in an "if bsis is not empty then ....", but I want to know why this select is doing this.
TIA
2006 Jun 15 5:14 PM
Hi,
If the for all entries table is empty, it will bring all the records. u need to implement a check that that itab should not be empty before executing select.
<b>IF NOT t_bukrs_rbeln[] IS INITIAL.</b>
select bukrs
hkont
belnr
waers
shkzg
wrbtr
prctr
into corresponding fields of table t_bsis
from bsis
for all entries in t_bukrs_rbeln
where bukrs eq t_bukrs_rbeln-bukrs
and zuonr eq p_sys
and gjahr eq p_gjahr.
<b>ENDIF.</b>
Sreedhar
I have this piece of code:
select bukrs
hkont
belnr
waers
shkzg
wrbtr
prctr
into corresponding fields of table t_bsis
from bsis
for all entries in t_bukrs_rbeln
where bukrs eq t_bukrs_rbeln-bukrs
and zuonr eq p_sys
and gjahr eq p_gjahr.
When the table t_bukrs_rbeln has items, the select is correct but, I noticed that, when the table t_bukrs_rbeln is empty, then the select brings ALL the entries from the table bsis.
I can nest this code in an "if bsis is not empty then ....", but I want to know why this select is doing this.
TIA
2006 Jun 15 5:14 PM
Hi,
If the for all entries table is empty, it will bring all the records. u need to implement a check that that itab should not be empty before executing select.
<b>IF NOT t_bukrs_rbeln[] IS INITIAL.</b>
select bukrs
hkont
belnr
waers
shkzg
wrbtr
prctr
into corresponding fields of table t_bsis
from bsis
for all entries in t_bukrs_rbeln
where bukrs eq t_bukrs_rbeln-bukrs
and zuonr eq p_sys
and gjahr eq p_gjahr.
<b>ENDIF.</b>
Sreedhar
2006 Jun 15 5:15 PM
Hi,
All entries selects all data when table is empty.
use
if not t_bukrs_rbeln is initial.
endif.
Regards
Amole
2006 Jun 15 5:16 PM
that is because you are missing this..
<b>if not t_bukrs_rbeln[] is initial.</b>
select bukrs
hkont
belnr
waers
shkzg
wrbtr
prctr
into corresponding fields of table t_bsis
from bsis
for all entries in t_bukrs_rbeln
where bukrs eq t_bukrs_rbeln-bukrs
and zuonr eq p_sys
and gjahr eq p_gjahr.
<b>endif.</b>
2006 Jun 15 5:17 PM
Hi,
When using FOR ALL ENTRIES in a select query, always check whether the internal table is empty or not.
eg.
if not itab is initial.
select bukrs
hkont
from bsis
into table it_bsis
for all entries in itab.......
endif.
This would skip the scenario which you are facing.
Best regards,
Prashant
2006 Jun 15 5:19 PM
Scott,
When ever you use 'for all entries' with an internal table, the select statement tries to pick up all records matching with the records in the internal table. If the internal table is empty then it will pick up all entries from the table you are selecting. So you always check whether the internal table is initial or not.
Thanks,
Message was edited by: Naren Somen
2006 Jun 15 5:17 PM
You must check that the table has entries before doing the SELECT FOR ALL ENTRIES. Its a good idea to make sure that it is sorted by the key.
check NOT t_bukrs_rbeln[] is initial.
sort t_bukrs_rbeln ascending by bukrs.
select bukrs
hkont
belnr
waers
shkzg
wrbtr
prctr
into corresponding fields of table t_bsis
from bsis
for all entries in t_bukrs_rbeln
where bukrs eq t_bukrs_rbeln-bukrs
and zuonr eq p_sys
and gjahr eq p_gjahr.Regards,
Rich Heilman
2006 Jun 15 5:31 PM
FOR ALL ENTRIES IN itab always brings in all entries if itab is empty. Check this <a href="http://help.sap.com/saphelp_47x200/helpdata/en/fc/eb3a1f358411d1829f0000e829fbfe/content.htm">link</a>.
2006 Jun 15 5:23 PM
Hi,
when <b>t_bukrs_rbeln</b> is initial
the select eliminates the where clause for the table
if u wnat to cross check
1) just put the break point before the select query. execute till there and stop
2) go to ST05
3) activate trace
4) again come back execute the select query
5) go back again to ST05 deactive the trace and see the log u will fine the selct query prepaid by the ABAP which run on the database.
Regards
Please mark Helpful Answers
4) come to the
2006 Jun 15 5:24 PM
Hi Scott,
If you execute Table BSIS in SE16 without giving any field for selection, it will display all the BSIS records. Hence you need to check t_bukrs_rbeln internal table before selection from BSIS.
IF not t_bukrs_rbeln[] is initial.
select bukrs
hkont
belnr
waers
shkzg
wrbtr
prctr
into corresponding fields of table t_bsis
from bsis
for all entries in t_bukrs_rbeln
where bukrs eq t_bukrs_rbeln-bukrs
and zuonr eq p_sys
and gjahr eq p_gjahr.
endif.
Cheers,
Vikram
Pls reward for helpful replies!!
2006 Jun 15 5:26 PM
Hi Scott
first u check this IF NOT t_bukrs_rbeln[] IS INITIAL.
if u dont have any values in t_bukrs_rbeln table then select will be skipped.i think this will help u...
IF NOT t_bukrs_rbeln[] IS INITIAL.
select bukrs
hkont
belnr
waers
shkzg
wrbtr
prctr
into corresponding fields of table t_bsis
from bsis
for all entries in t_bukrs_rbeln
where bukrs eq t_bukrs_rbeln-bukrs
and zuonr eq p_sys
and gjahr eq p_gjahr.
if sy-subrc = 0.
sort t_bukrs_rbeln by bukrs hkont belnr
endif.
Thanks
Vikranth Khimavath
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |