‎2005 Dec 15 1:58 PM
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.
‎2005 Dec 15 2:02 PM
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
‎2005 Dec 15 2:02 PM
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
‎2005 Dec 15 2:08 PM
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
‎2005 Dec 15 2:37 PM
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
‎2005 Dec 15 3:45 PM
Why are you including BSAK at all? You're not retrieving any data from it.
Rob
‎2005 Dec 15 4:02 PM
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.