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

Inner join problem

Former Member
0 Likes
888

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
829

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

5 REPLIES 5
Read only

Former Member
0 Likes
829

Please read the help on using brackets in logical expressions.

Rob

Read only

Former Member
0 Likes
829

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..

Read only

Former Member
0 Likes
830

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

Read only

0 Likes
829

Hi Ruchi,

Thank you so much for your solution.I rewarded you the points.

Thanks,

Swapna.

Read only

Former Member
0 Likes
829

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