‎2008 Nov 20 5:57 PM
Hi All,
I am writing the inner join for the tables LFA1 and LFB1. like this.
SELECT alifnr aktokk aname1 asortl a~adrnr
bbukrs bzterm
INTO CORRESPONDING FIELDS OF TABLE it_lfb1
FROM lfa1 AS a
INNER JOIN lfb1 AS b
ON blifnr = alifnr
WHERE asperr = ' ' AND aloevm = ' '
AND aktokk = 'ZZ03' OR aktokk = 'ZZ04' OR a~ktokk = 'ZZ05'
AND b~bukrs = p_cocode.
I am using the company code 4402
When iam getting the data 3 extra records are coming which are not avaliable in the company code 4402
<<text removed>>.
Edited by: Matt on Nov 21, 2008 11:57 AM
‎2008 Nov 21 2:54 AM
Hi swapna,
Try this:-
SELECT a~lifnr
a~ktokk
a~name1
a~sortl
a~adrnr
b~bukrs
b~zterm
INTO CORRESPONDING FIELDS OF TABLE it_lfb1
FROM lfa1 AS a
INNER JOIN lfb1 AS b
ON blifnr = alifnr
WHERE ( asperr = ' ' AND aloevm = ' ' )
AND( aktokk = 'ZZ03' OR aktokk = 'ZZ04' OR a~ktokk = 'ZZ05' )
AND b~bukrs = p_cocode.
Hope this solves ur problem.
Thanks & Regards
Ruchi Tiwari
‎2008 Nov 20 6:12 PM
Please read the help on using brackets in logical expressions.
Rob
‎2008 Nov 20 10:18 PM
Hi,
Better use for all entries... its better for performance wise.
select x y x from tab1 into it_tab1.
select x m n from tab2 into it_tab2
for all entries in it_tab1
where x = it_tab1-x.
Thanks & Regards,
Krishna..
‎2008 Nov 21 2:54 AM
Hi swapna,
Try this:-
SELECT a~lifnr
a~ktokk
a~name1
a~sortl
a~adrnr
b~bukrs
b~zterm
INTO CORRESPONDING FIELDS OF TABLE it_lfb1
FROM lfa1 AS a
INNER JOIN lfb1 AS b
ON blifnr = alifnr
WHERE ( asperr = ' ' AND aloevm = ' ' )
AND( aktokk = 'ZZ03' OR aktokk = 'ZZ04' OR a~ktokk = 'ZZ05' )
AND b~bukrs = p_cocode.
Hope this solves ur problem.
Thanks & Regards
Ruchi Tiwari
‎2008 Nov 21 10:32 AM
Hi Ruchi,
Thank you so much for your solution.I rewarded you the points.
Thanks,
Swapna.
‎2008 Nov 21 3:25 AM
Hi,
I think the problem occurs on the AND and OR statement:
SELECT alifnr aktokk aname1 asortl a~adrnr
bbukrs bzterm
INTO CORRESPONDING FIELDS OF TABLE it_lfb1
FROM lfa1 AS a
INNER JOIN lfb1 AS b
ON blifnr = alifnr
WHERE asperr = ' ' AND aloevm = ' '
AND aktokk = 'ZZ03' OR aktokk = 'ZZ04' OR a~ktokk = 'ZZ05'
" change to AND a~ktokk in ('ZZ03', 'ZZ04', 'ZZ05')
AND b~bukrs = p_cocode.
I think it can solve the problem.
Regards,
Chris Gu
Edited by: Gu Chris on Nov 21, 2008 4:25 AM