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

naimkhans_babi
Active Participant
0 Likes
609

Dear firends

How are you,,,

I am facing a problem in inner join...please have a look at the code:

select aequnr atplnr a~werk

bequnr bwerks b~stlnr

from v_equi as a

inner join eqst as b

on aequnr = bequnr

into corresponding fields of table it_eqst

where equnr in equp_no.

if sy-subrc = 0.

select stlnr stlkn idnrk posnr

from stpo

into corresponding fields of table t_stpo

for all entries in t_eqst

where stlnr = t_eqst-stlnr and

stlty = 'E'.

this code should give me equipment number as well as functional location, but i am having this message

"The column name "EQUNR" has two meanings. ABAP/4 Open SQL statement."

plese tell me where i am doing mistake, apart from inner join this query will be this way:

"select equnr from v_equi

into corresponding fields of table t_equi

where tplnr in s_tplnr and

equnr in s_equnr.

if sy-subrc = 0.

select equnr stlnr

from eqst

into corresponding fields of table t_eqst

for all entries in t_equi

where equnr = t_equi-equnr.

if sy-subrc = 0.

select stlnr stlkn idnrk posnr

from stpo

into corresponding fields of table t_stpo

for all entries in t_eqst

where stlnr = t_eqst-stlnr and

stlty = 'E'.

but it didnt produce me functional location..

please help me to solve this problem any code, suggestion , will be greate help of mine

thanking you,

regards,

naim

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
554

Naim,

Its a simple mistake

select aequnr atplnr a~werk

bequnr bwerks b~stlnr

from v_equi as a

inner join eqst as b

on aequnr = bequnr

into corresponding fields of table it_eqst

where <b>a~equnr</b> in equp_no.

if sy-subrc = 0.

select stlnr stlkn idnrk posnr

from stpo

into corresponding fields of table t_stpo

for all entries in t_eqst

where stlnr = t_eqst-stlnr and

stlty = 'E'.

Every field that exist in both the tables should be accompanied by the table name.

Regards,

Ravi

Note : Please close the thread if this solves the issue.

4 REPLIES 4
Read only

Former Member
0 Likes
554

select aequnr atplnr a~werk

b~stlnr

from v_equi as a

inner join eqst as b

on aequnr = bequnr

into corresponding fields of table it_eqst

where a~equnr in equp_no.

if sy-subrc = 0.

select stlnr stlkn idnrk posnr

from stpo

into corresponding fields of table t_stpo

for all entries in t_eqst

where stlnr = t_eqst-stlnr and

stlty = 'E'.

just delete bequnr than it is ok .... because thee is already aequnr

Read only

Former Member
0 Likes
554

hi naim,

select aequnr atplnr a~werk

bequnr bwerks b~stlnr

from v_equi as a

inner join eqst as b

on aequnr = bequnr

into corresponding fields of table it_eqst

where <b>a-equnr</b> in equp_no.

if sy-subrc = 0.

select stlnr stlkn idnrk posnr

from stpo

into corresponding fields of table t_stpo

for all entries in t_eqst

where stlnr = t_eqst-stlnr and

stlty = 'E'.

<b>reward if useful..</b>

Read only

Former Member
0 Likes
555

Naim,

Its a simple mistake

select aequnr atplnr a~werk

bequnr bwerks b~stlnr

from v_equi as a

inner join eqst as b

on aequnr = bequnr

into corresponding fields of table it_eqst

where <b>a~equnr</b> in equp_no.

if sy-subrc = 0.

select stlnr stlkn idnrk posnr

from stpo

into corresponding fields of table t_stpo

for all entries in t_eqst

where stlnr = t_eqst-stlnr and

stlty = 'E'.

Every field that exist in both the tables should be accompanied by the table name.

Regards,

Ravi

Note : Please close the thread if this solves the issue.

Read only

Former Member
0 Likes
554

Just make the following correction:

select aequnr atplnr a~werk

bequnr bwerks b~stlnr

from v_equi as a

inner join eqst as b

on aequnr = bequnr

into corresponding fields of table it_eqst

**where equnr in equp_no.

where <b>a~equnr</b> in equp_no.