2008 Jan 20 10:12 AM
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.
2008 Jan 20 11:20 AM
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..
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.
2008 Jan 20 10:26 AM
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.
2008 Jan 20 10:43 AM
I have trued 'corresponding filelds of' and the fileds are also matching at the on cluase. Still getting the same error.
2008 Jan 20 11:20 AM
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.
2008 Jan 20 11:41 AM
Thankyou. Now i have added that field also. still not working.
2008 Jan 20 12:28 PM
hi
could you please try the query by removing a bracket at 'from' in select statement.
i mean use only one bracket.
2008 Jan 20 12:40 PM
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.
2008 Jan 21 1:23 AM
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.
2008 Jan 21 1:14 PM
hi,
once u got the correct solution, could u please
post the right answer here.
regards
2008 Jan 21 6:22 PM
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.
2008 Jan 21 8:55 AM
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
2008 Jan 21 10:40 AM
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.
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |