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

Join not working

Former Member
0 Likes
1,043

Hello,

I have this code but it doesnt do not. This is a simple one with 2 tables. Given the case I need to join 5 table is the join the correct method because I heard that it is nort recomended for so many tables.

tables: mbew, marc, ZJOIN.

data :

i_zjoin type standard table of zjoin,

w_zjoin type zjoin.

select single amatnr abwkey abwtar bwerks

into (zjoin-matnr, zjoin-bwkey, zjoin-bwtar, zjoin-werks)

from marc as b inner join mbew as a

on amatnr = bmatnr

where b~matnr = 'R2R-EQUIPMENT'.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,008

HI,

You can do join till 3 tables ...if you want to get the data from the 5 tables then you use the JOIn on the basic tables and then Using FOR ALL entries get the data from other table.

Check the below code

select single a~matnr a~bwkey a~bwtar b~werks
into corresponding field of table i_zjoin       
from marc as b inner join mbew as a
on a~matnr = b~matnr
where b~matnr = 'R2R-EQUIPMENT'.

IF NOT i_join[] is iniitial.
 SELECT * FROm marc into table i_marc 
   for all entries in i_zjoin 
    where matnr = i_zjoin-matnr and
             werks = i_zjoin-werks.
ENDIF.



8 REPLIES 8
Read only

Former Member
0 Likes
1,009

HI,

You can do join till 3 tables ...if you want to get the data from the 5 tables then you use the JOIn on the basic tables and then Using FOR ALL entries get the data from other table.

Check the below code

select single a~matnr a~bwkey a~bwtar b~werks
into corresponding field of table i_zjoin       
from marc as b inner join mbew as a
on a~matnr = b~matnr
where b~matnr = 'R2R-EQUIPMENT'.

IF NOT i_join[] is iniitial.
 SELECT * FROm marc into table i_marc 
   for all entries in i_zjoin 
    where matnr = i_zjoin-matnr and
             werks = i_zjoin-werks.
ENDIF.



Read only

0 Likes
1,008

Hi ,

Now it gives this erroe

Field "corresponding is un known. It is nethier in one of the specified tables nor defined by a "data :" statement

Read only

0 Likes
1,008

HI,

Check now ..it works

SELECT SINGLE a~matnr a~bwkey a~bwtar b~werks
FROM marc AS b INNER JOIN mbew AS a
INTO CORRESPONDING FIELDS OF TABLE i_zjoin
ON a~matnr = b~matnr
WHERE b~matnr = 'R2R-EQUIPMENT'.

IF NOT i_join[] IS INIITIAL.
  SELECT * FROM marc INTO  TABLE i_marc
    FOR ALL ENTRIES IN i_zjoin
     WHERE matnr = i_zjoin-matnr AND
              werks = i_zjoin-werks.
ENDIF.

Read only

0 Likes
1,008

Still I get this error

Incorrect structure of FROM clause

Read only

Former Member
0 Likes
1,008

What do you mean that it is not working? Syntax error, dump, incorrect results?

Rob

Read only

0 Likes
1,008

Zjoion dosent have anything after runnig the code.

Read only

Former Member
0 Likes
1,008

Hi David,

see the examples and use the appropriate one...

<< Cut and paste without attribution from http://www.saptechies.com/join-in-open-sql/ removed >>

Regards,

Prabhudas

Edited by: Rob Burbank on Apr 2, 2009 1:37 PM

Read only

Former Member
0 Likes
1,008

David - I don't see anything wrong with your original code. The fact that it doesn't return any value may just mean that there is no data to select. Have you run the material through the conversion exit before SELECTing?

Rob