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

Syntax error Inner Join?

Former Member
0 Likes
1,197

Everything was OK till I added last table MBEW for field d~bklas. The field BKLAS does exist in MBEW. Syntax error:wrong table or alias "D"...anybody?...Thank-You!

SELECT amatnr awerks amaabc adismm

b~maktx

cmtart cmatkl c~zzsasi_dept

czzsasi_dept czz_sasi_sub_dept c~zzpos1

czzpos1 czzpos2 czzpos3 czzpos4 c~zzpos5

d~bklas

INTO CORRESPONDING FIELDS OF TABLE t_outdata

FROM marc AS a INNER JOIN makt AS b

ON amatnr = bmatnr

INNER JOIN mara AS c

ON amatnr = cmatnr

WHERE a~werks IN s_werks

inner join mbew as d

on amatnr = dmatnr

where d~bwkey in s_werks.

11 REPLIES 11
Read only

Former Member
0 Likes
1,145

SELECT amatnr awerks amaabc adismm

b~maktx

cmtart cmatkl c~zzsasi_dept

czzsasi_dept czz_sasi_sub_dept c~zzpos1

czzpos1 czzpos2 czzpos3 czzpos4 c~zzpos5

d~bklas

INTO CORRESPONDING FIELDS OF TABLE t_outdata

FROM marc AS a INNER JOIN makt AS b

ON amatnr = bmatnr

INNER JOIN mara AS c

ON amatnr = cmatnr

<b>inner join mbew as d

ON amatnr = dmatnr</b>

WHERE a~werks IN s_werks

where d~bwkey in s_werks.

Read only

Laxmana_Appana_
Active Contributor
0 Likes
1,145

Hi,

Check the where condition , it is written two times.

Laxman

Read only

0 Likes
1,145

Consolidate 2 WHERE statements in to one as mentioned.

Thanks,

Read only

Former Member
0 Likes
1,145

Hi Tom,

Here is the modified query.

SELECT a~matnr a~werks a~maabc a~dismm
b~maktx
c~mtart c~matkl c~zzsasi_dept
c~zzsasi_dept c~zz_sasi_sub_dept c~zzpos1
c~zzpos1 c~zzpos2 c~zzpos3 c~zzpos4 c~zzpos5 
d~bklas


INTO CORRESPONDING FIELDS OF TABLE t_outdata
FROM marc AS a INNER JOIN makt AS b
ON a~matnr = b~matnr
INNER JOIN mara AS c
ON a~matnr = c~matnr
inner join mbew as d
on a~matnr = d~matnr
WHERE a~werks IN s_werks
AND   d~bwkey in s_werks.

<b>Reward points if it helps.</b>

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,145

You problem is not with that field, you can't have a WHERE condition in your join logic, it must be a the end.




select a~matnr a~werks a~maabc a~dismm
b~maktx
c~mtart c~matkl 
c~zzsasi_dept
c~zzsasi_dept c~zz_sasi_sub_dept c~zzpos1
c~zzpos1 c~zzpos2 c~zzpos3 c~zzpos4 c~zzpos5
d~bklas
into corresponding fields of table t_outdata
       from marc as a 
          inner join makt as b
             on a~matnr = b~matnr
<b>          inner join mara as c
             on a~matnr = c~matnr</b>
          inner join mbew as d
             on a~matnr = d~matnr
                   where <b> a~werks in s_werks</b>
                      and d~bwkey in s_werks.


Regards,

Rich Heilman

Read only

Former Member
0 Likes
1,145

hi,

SELECT a~matnr ...

b~maktx ..

c~mtart ..

d~bklas ..

INTO CORRESPONDING FIELDS OF TABLE t_outdata

FROM marc AS a

INNER JOIN makt AS b

ON amatnr = bmatnr

INNER JOIN mara AS c

ON amatnr = cmatnr

inner join mbew as d

on amatnr = dmatnr.

WHERE a~werks IN s_werks

and d~bwkey in s_werks.

Also, check this....

SELECT pcarrid pconnid ffldate bbookid

INTO CORRESPONDING FIELDS OF TABLE itab

FROM ( ( spfli AS p

INNER JOIN sflight AS f ON pcarrid = fcarrid AND

pconnid = fconnid )

INNER JOIN sbook AS b ON bcarrid = fcarrid AND

bconnid = fconnid AND

bfldate = ffldate )

WHERE p~cityfrom = 'FRANKFURT' AND

p~cityto = 'NEW YORK' AND

fseatsmax > fseatsocc.

Regards,

Richa.

Read only

0 Likes
1,145

Hi,

Try this way..

SELECT a~matnr a~werks a~maabc a~dismm
b~maktx
c~mtart c~matkl c~zzsasi_dept
c~zzsasi_dept c~zz_sasi_sub_dept c~zzpos1
c~zzpos1 c~zzpos2 c~zzpos3 c~zzpos4 c~zzpos5
d~bklas
INTO CORRESPONDING FIELDS OF TABLE t_outdata
    FROM marc AS a 
  INNER JOIN makt AS b
    ON a~matnr = b~matnr
  INNER JOIN mara AS c
      ON a~matnr = c~matnr
   INNER JOIN mbew AS d
       ON d~matnr = c~matnr
WHERE a~werks IN s_werks
INNER JOIN mbew AS d
ON a~matnr = d~matnr
WHERE d~bwkey IN s_werks.

Regards

vijay

Read only

Former Member
0 Likes
1,145

You are selection zzsasi_dept twice. That's not your error, but you might want to look into it.

Rob

Read only

Former Member
0 Likes
1,145

hi tom,

SELECT amatnr awerks amaabc adismm

b~maktx

cmtart cmatkl c~zzsasi_dept

czzsasi_dept czz_sasi_sub_dept c~zzpos1

czzpos1 czzpos2 czzpos3 czzpos4 c~zzpos5

d~bklas

INTO CORRESPONDING FIELDS OF TABLE t_outdata

FROM marc AS a INNER JOIN makt AS b

ON amatnr = bmatnr

INNER JOIN mara AS c

ON amatnr = cmatnr

inner join mbew as d

on amatnr = dmatnr

WHERE a~werks IN s_werks and

d~bwkey in s_werks.

hope this helps.

reward if helpful.

regards,

keerthi.

Read only

Former Member
0 Likes
1,145

HI Tom

You have forgotten <b>ON</b> before mbew.

Regards,

Laxmi

Read only

Former Member
0 Likes
1,145

Your correct code is as follows


SELECT a~matnr            a~werks a~maabc a~dismm
       b~maktx            c~mtart c~matkl c~zzsasi_dept
       c~zz_sasi_sub_dept c~zzpos1 c~zzpos2
       c~zzpos3           c~zzpos4 c~zzpos5 d~bklas
  INTO CORRESPONDING FIELDS OF TABLE t_outdata
  FROM marc AS a INNER JOIN makt AS b ON a~matnr = b~matnr
                 INNER JOIN mara AS c ON a~matnr = c~matnr
                 INNER JOIN mbew AS d ON a~matnr = d~matnr
 WHERE a~werks IN s_werks
   AND d~bwkey IN s_werks.