Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

SELECT QUERY

Former Member
0 Likes
566

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?

3 REPLIES 3
Read only

Former Member
0 Likes
465

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.

Read only

Former Member
0 Likes
465

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

Read only

Former Member
0 Likes
465

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