‎2010 Mar 16 12:39 PM
Hello Experts,
can anyone please help me translate an Oracle select statement into ABAP, the main problem is reading from more than 4 tables in a single select query such as:
select t1.F1, t1.F2, t2.F3, t3.F4, t3.F5
from tabl1 t1, table2 t2, table3 t3, table4 t4
where t1.PK = t2.FK
and t1.PK = t3.FK
and t1.PK(+) = t2.FK
and t3.PK = t4.FK
and t4.F6 = 'VALUE'
where table1,2,3,4 are table names / F1,2,3,4 are table fields / left outer join / and 'VALUE' is any value passed to query / FK foreign key / PK primary key
note that table4 is used to setup the where clase and no fields are retrieved from it.
can this be translated into ABAP query? please help
Best Regards,
‎2010 Mar 16 12:48 PM
Hi
It's shoul look something like this....
But not recommended to much...
select t1F1, t1F2, t2F3, t3F4, t3~F5
from tabl1 as t1 left outer join table2 as t2
on t1PK = t2FK
inner join table3 as t3
on t1PK = t3FK
inner join table4 as t4
on t3PK = t4FK
where t4~F6 = 'VALUE'
Best Regards
Yossi Rozenberg
‎2010 Mar 16 12:45 PM
Hi,
There must a option like Bind variable in your screen. Are you running a SQL trace in ST05?
Regards,
Vijay V
‎2010 Mar 16 1:29 PM
Actually I have a field that I should retrieve data to from different tables, so instead of making 3 or 4 queries I thought it is possible to write in my program a single query. but since this is not recommended I will try to get data from each table seperately.
‎2010 Mar 16 1:33 PM
Hi,
Try to use "for all entries" or you can find a suitable Function module that can meet your requirement. I think you can write a join upto 3 tables if the requirement is there.
Regards,
Vijay V
‎2010 Mar 16 1:34 PM
Samir
As far as i know you should avoid very complex joins (4 tables it's too much and not afficient but join of 2 tables for example it's more than welcome ( based on situation of course),but you can use all kinds of other tools like for all entries for example)
Best Regards
Yossi Rozenberg
‎2010 Mar 16 12:48 PM
Hi
It's shoul look something like this....
But not recommended to much...
select t1F1, t1F2, t2F3, t3F4, t3~F5
from tabl1 as t1 left outer join table2 as t2
on t1PK = t2FK
inner join table3 as t3
on t1PK = t3FK
inner join table4 as t4
on t3PK = t4FK
where t4~F6 = 'VALUE'
Best Regards
Yossi Rozenberg