04-01-2008 7:13 PM
i am doing an select like this
FROM bsak
INTO TABLE t_cleared
FOR ALL ENTRIES IN t_data1
WHERE lifnr = t_data1-lifnr
AND bukrs IN s_bukrs
AND augdt GT p_kdate
AND belnr NE bsik-augbl
AND budat LE p_kdate
AND bschl = 31.
AND hkont IN s_hkont.
now the problem is that the table t_data1 has got no records for this particular case and moreover for the particular s_hkont and bukrs combination there are no records in the table but still this select is fetching all the records
wat is wrong here?
04-01-2008 7:17 PM
You know the answer. t_data1 has no records..so all the records will be fetched if you use for all entries addition. It's a standard behaviour.
Solution:
Execute the select query only when t_data1[] is not initial.
04-01-2008 9:36 PM
We have to check the internal table not initial whenever we use FOR ALL ENTRIES Statement
If t_data1[] is balnk. it fetches all the record.
So check for t_data1[] not inital.
IF NOT t_data1[] is INITIAL.
Select *
FROM bsak
INTO TABLE t_cleared
FOR ALL ENTRIES IN t_data1
WHERE lifnr = t_data1-lifnr
AND bukrs IN s_bukrs
AND augdt GT p_kdate
AND belnr NE bsik-augbl
AND budat LE p_kdate
AND bschl = 31.
AND hkont IN s_hkont.
ENDIF
04-02-2008 12:30 AM
Hello,
You cant fetch any data from a select stm if there arent values on t_data1
please fisrt check if there are values....
ie:
DESCRIBRE TABLE t_data1 LINES num.
if num > 0.
<YOUR CODE>
endif.
Hope this helps
Gabriel P