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

ABAP SQL

Former Member
0 Likes
711

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,

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
674

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

5 REPLIES 5
Read only

vijaymanikandan
Contributor
0 Likes
674

Hi,

There must a option like Bind variable in your screen. Are you running a SQL trace in ST05?

Regards,

Vijay V

Read only

0 Likes
674

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.

Read only

0 Likes
674

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

Read only

0 Likes
674

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

Read only

Former Member
0 Likes
675

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