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

selection statement

Former Member
0 Likes
809

in my report i am selectin data from bsak table into itab2 for all entries in itab1.

itab1 has got only one record but the problem is that it is picking all the data not only the data corresponding to the data in itab1.

in itab1 i am selecting data based on the vendor no enetred by the user in seelcetion screen

this is the code for second selectionm

SELECT bukrs "getting details of open items based on user input

lifnr

umskz

augdt

augbl

belnr

budat

zterm

waers

bschl

bstat

zfbdt

shkzg

zbd1t

zbd2t

zbd3t

rebzg

rebzt

bldat

dmbtr

FROM bsak

INTO TABLE t_cleared

FOR ALL ENTRIES IN t_data1

WHERE bukrs IN s_bukrs

AND lifnr = t_data1-lifnr

AND augdt LE p_kdate

OR augdt LE p_kdate

AND belnr NE bsik-augbl

AND bschl = 31.

ENDFORM. "f_get_cleared_data

7 REPLIES 7
Read only

abdulazeez12
Active Contributor
0 Likes
794

Hi

Modify ur code as follows:

SELECT bukrs "getting details of open items based on user input

lifnr

umskz

augdt

augbl

belnr

budat

zterm

waers

bschl

bstat

zfbdt

shkzg

zbd1t

zbd2t

zbd3t

rebzg

rebzt

bldat

dmbtr

FROM bsak

INTO TABLE t_cleared

FOR ALL ENTRIES IN t_data1

WHERE lifnr = t_data1-lifnr

AND bukrs IN s_bukrs

AND augdt LE p_kdate

OR augdt LE p_kdate

AND belnr NE bsik-augbl

AND bschl = 31.

ENDFORM. "f_get_cleared_data

Read only

Former Member
0 Likes
794

Hi,

What are the fields in itab1 and from which table are you filling the internal table itab1 ?

Regards

Read only

0 Likes
794

same fields as in itab2 and i am getting the data from bsik table

Read only

Former Member
0 Likes
794

Hi,

When you are selecting from BSAK table , in order to get a single entry you need to enter all the key fields. Unless you enter all the key fields you may get multiple records.

Tell me thru which table are u filling itab1 and what are those fields.

Regards.

Read only

Former Member
0 Likes
794

Hi,

When you are filling into the internal table itab1, fetch all the key fields from the table BSIK.

I think you should not have any problem then.

Regards.

Read only

Former Member
0 Likes
794

Make sure ur internal table has data.

If internal table has no data, FOR ALL ENTRIES fetches all the records from the data base .

Regards,

Ajay

Read only

vinod_vemuru2
Active Contributor
0 Likes
794

Hi,

Check ur where clause. Why u gave condition OR augdt LE p_kdate. Let me know this. Just remove this condition. U can get the proper out put.

WHERE bukrs IN s_bukrs

AND lifnr = t_data1-lifnr

AND augdt LE p_kdate

OR augdt LE p_kdate

AND belnr NE bsik-augbl

AND bschl = 31.

Thanks,

Vinod.