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. error. too long. unique. unique

Former Member
0 Likes
1,168

hi,

I am a beginer to ABAP and trying to do an inner join using 3 tables that are given by SAP

scustom, spfli, and sbook. I want to join these 3 tables and get

the customer booking info and wants the result of

customer_no , cust_name, Booking_ID, City_From, City_To, etc.

my query i s below.

select cid cname bbookid bconnid bfldate fcityfrom f~cityto

into table it_scust

from ((scustom as c inner join sbook as b

on cid = bcustomid)

inner join spfli as f on fconnid = bconnid and fcarrid = bcarrid).

when i execute the program i am getting the error that the 'query is too long. unique. unique. unique.'.

If I am joing only two tables it is working fine. Is there something wrong with my query? Any ideas on this? Please help.

Thanks in advance.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,136

HI..

U have done a small mistake...

In the select query u r giving the condiation as fcarrid = bcarrid.

but you r not fetching that into your internal table.

you need to fetch CARRID also.

then onle you will get it.

try like this.

select cid cname bbookid bfldate fconnid fcarrid fcityfrom fcityto

into table it_scust

from ((scustom as c inner join sbook as b

on cid = bcustomid)

inner join spfli as f on fconnid = bconnid and fcarrid = bcarrid).

Now you will get.

Regards

Sandeep.

Hi,

The only problem is spaces between '((' in from clause. after giving spaces like ' ( ( ' this , it worked fine.

Also omiting '((' in from clause entirely, worked fine.

select cid cname bbookid bconnid bfldate fcityfrom f~cityto

into table it_scust

from ( ( scustom as c inner join sbook as b

on cid = bcustomid)

inner join spfli as f on fconnid = bconnid and fcarrid = bcarrid).

Thanks.

11 REPLIES 11
Read only

Former Member
0 Likes
1,136

Check first: it_scust needs to have the fields you select.

In case you do have more fields use command "into corresponding fields of table"

As I did not work with those tables (aren't they from standard SAP examples / courses) you should also check the ON referring that values match.

Read only

0 Likes
1,136

I have trued 'corresponding filelds of' and the fileds are also matching at the on cluase. Still getting the same error.

Read only

Former Member
0 Likes
1,137

HI..

U have done a small mistake...

In the select query u r giving the condiation as fcarrid = bcarrid.

but you r not fetching that into your internal table.

you need to fetch CARRID also.

then onle you will get it.

try like this.

select cid cname bbookid bfldate fconnid fcarrid fcityfrom fcityto

into table it_scust

from ((scustom as c inner join sbook as b

on cid = bcustomid)

inner join spfli as f on fconnid = bconnid and fcarrid = bcarrid).

Now you will get.

Regards

Sandeep.

Read only

0 Likes
1,136

Thankyou. Now i have added that field also. still not working.

Read only

0 Likes
1,136

hi

could you please try the query by removing a bracket at 'from' in select statement.

i mean use only one bracket.

Read only

0 Likes
1,136

hi,

please try this.

select c~id

c~name

b~bookid

b~connid

b~fldate

f~city

f~cityto

into table it_scust

from (scustom as c

INNER JOIN sbook as b

on cid = bcustomid

INNER JOIN spfli as f

on fconnid = bconnid

AND fcarrid =bcarrid).

if helpful, could u please reward some points.

Read only

0 Likes
1,136

I think if you check the SAP Documentation it tells to use two brackets.

[...]

into table it_scust

from ( ( scustom as c

INNER JOIN sbook as b

on cid = bcustomid )

INNER JOIN spfli as f

on fconnid = bconnid

AND fcarrid = bcarrid ).

Further suggestions on this matter.

Split up the join into several selects to check target structure / table.

After that build it up step by step and condition by condition.

Read only

0 Likes
1,136

hi,

once u got the correct solution, could u please

post the right answer here.

regards

Read only

0 Likes
1,136

Hi,

The only problem is spaces between '((' in from clause. after giving spaces like ' ( ( ' this , it worked fine.

Also omiting '((' in from clause entirely, worked fine.

select cid cname bbookid bconnid bfldate fcityfrom f~cityto

into table it_scust

from ( ( scustom as c inner join sbook as b

on cid = bcustomid)

inner join spfli as f on fconnid = bconnid and fcarrid = bcarrid).

Thanks.

Read only

Former Member
0 Likes
1,136

select

c~id

c~name

b~bookid

b~connid

b~fldate

f~cityfrom

f~cityto

into table it_scust

from scustom as c inner join sbook as b

on cid = bcustomid

inner join spfli as f on bconnid = fconnid and bcarrid = fcarrid.

use this it works

Read only

Former Member
0 Likes
1,136

Hi neeraja,

what ever the code you have written is fine but it is unique/ too long means the code you have written is not ending perfectly which is not identified by syntax error. your code is

select cid cname bbookid bconnid bfldate fcityfrom f~cityto

into table it_scust

from ((scustom as c inner join sbook as b

on cid = bcustomid)

inner join spfli as f on fconnid = bconnid and fcarrid = bcarrid).

iam sending the same code but with little modification just try this u will get the output.

select cid cname bbookid bconnid bfldate fcityfrom f~cityto

into table it_scust

from (scustom as c inner join sbook as b

on cid = bcustomid)

inner join spfli as f on fconnid = bconnid and fcarrid = bcarrid.

find the difference what i made.

pls reward points if it is helpful.