Application Development 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: 

Dynamic table name according to a field value in left outer join

hagit
Active Participant
0 Kudos
246

Hello Experts,

In left outer join the table in the right side depends on the value of a field in the left side table.

For example

1. Select from tbl1

2. If tbl1-fld2 = 1

then

Select fld1 into corresponding …

From tbl1

Left outer join tbl2_a

Else

Select fld1 into corresponding …

From tbl1

Left outer join tbl2_b

Something like that:

Select fld1 into corresponding …

From tbl1

Left outer join case tbl1~fld2 = 1 (tbl2_a)

Else (tbl2_b)

On ….

How can I write it in ABAP's select statement?

Thank you

Hagit

3 REPLIES 3

Sandra_Rossi
Active Contributor
214

Formatting of question is awful, difficult to read and understand.

I think the question is better written this way (according to me):

-----------------------------------------------------------------------------------------------------------

In left outer join the table in the right side depends on the value of a field in the left side table.

For example

Select from tbl1

If tbl1-fld2 = 1 then
    Select fld1 into corresponding …
    From tbl1
    Left outer join tbl2_a
Else
    Select fld1 into corresponding …
    From tbl1
    Left outer join tbl2_b

How can I write it in ABAP's select statement Something like below?

Select fld1 into corresponding …
From tbl1
Left outer join case tbl1~fld2 = 1 (tbl2_a)
Else (tbl2_b)
On ….

hagit
Active Participant
0 Kudos
214

sandra.rossi This is the question . What is the answer?

hagit
Active Participant
0 Kudos
214

I want to clarify that tbl2_a and tbl2_b are decided at runtime