Application Development 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: 

No Data Returned from SELECT

Former Member
0 Kudos

Hi,

No data is being returned when i execute this SELECT statement. Can you let me know where am i going wrong.

SELECT DISTINCT alifnr bbukrs c~dmbtr INTO CORRESPONDING FIELDS OF TABLE itab

FROM lfa1 AS a INNER JOIN lfb1 AS b ON alifnr = blifnr

INNER JOIN bsik AS c ON clifnr = blifnr AND

cbukrs = bbukrs

INNER JOIN bsak AS d ON dlifnr = clifnr AND

dbukrs = cbukrs

WHERE a~land1 NE 'XX' AND

b~bukrs between '100' and '200'.

SORT itab ASCENDING BY lifnr.

Thanks.

1 ACCEPTED SOLUTION

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

I think its because of the company code.




SELECT DISTINCT a~lifnr b~bukrs c~dmbtr INTO CORRESPONDING FIELDS OF TABLE itab
FROM lfa1 AS a INNER JOIN lfb1 AS b ON a~lifnr = b~lifnr
INNER JOIN bsik AS c ON c~lifnr = b~lifnr AND
c~bukrs = b~bukrs
INNER JOIN bsak AS d ON d~lifnr = c~lifnr AND
d~bukrs = c~bukrs
WHERE a~land1 NE 'XX' AND
<b>b~bukrs between '0100' and '0200'.</b>

Regards,

Rich Heilman

5 REPLIES 5

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

I think its because of the company code.




SELECT DISTINCT a~lifnr b~bukrs c~dmbtr INTO CORRESPONDING FIELDS OF TABLE itab
FROM lfa1 AS a INNER JOIN lfb1 AS b ON a~lifnr = b~lifnr
INNER JOIN bsik AS c ON c~lifnr = b~lifnr AND
c~bukrs = b~bukrs
INNER JOIN bsak AS d ON d~lifnr = c~lifnr AND
d~bukrs = c~bukrs
WHERE a~land1 NE 'XX' AND
<b>b~bukrs between '0100' and '0200'.</b>

Regards,

Rich Heilman

Former Member
0 Kudos

Hi Sachin,

1. First get lifnr,bukrs from lfa1 joined with lfb1. Sort on lifnr and bukrs. And, delete adjacent duplicates comparing lifnr and bukrs.

2. for these lifnr and bukrs values go to bsak and fetch the records, loop on this table and summate the values of dmbtr, to get total amount for each vendor/company code.

Basically, your select statement is wrong.

Regards,

Raj

andreas_mann3
Active Contributor
0 Kudos

sorry, but your select statement is bad !

you join 4 BIG tables in a join and select several bukrs!

alternatives:

1) use logical database kdf

2) split your select in master data , loop found master data and bukrs and select posting documents

regards Andreas

Former Member
0 Kudos

Why are you including BSAK at all? You're not retrieving any data from it.

Rob

Former Member
0 Kudos

Hi, I could get the data using your select statement. Please check all the tables whether the records exists for the joining condition. As you are using inner join, it might be possible that if the satisfied record does not exist in any one of the table, there may not be records selected.