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

Select with a dynamic value table

Former Member
0 Likes
861

Hello,

I have to tables t1 and t2. In the first table I have a field f1 which has the name of t2 as value.

How has to be the Select Statement

I tried

DATA: l_table TYPE CHAR5 .

Select v1 into l_table from t1

Select v2 into xx from (l_table).

But I get there allways an error and I could not find an starting point in seach for this problem.

Thank for any help

Regards

Henning

Edited by: Alvaro Tejada Galindo on Apr 10, 2008 5:15 PM

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
836

Hi,

the problem may be with select use select single.

or else give the error description.

DATA: l_table TYPE CHAR5 .

data:var(10).

Select SINGLE f1 into l_table from t1.

Select SINGLE f into var from (l_table)."here ensure that field F is there in table T2.

rgds,

bharat.

6 REPLIES 6
Read only

Former Member
0 Likes
836

Do like this



Select v1 into l_table from t1.
endselect.
Select v2 into xx from (l_table).
endselect.

Read only

Former Member
0 Likes
837

Hi,

the problem may be with select use select single.

or else give the error description.

DATA: l_table TYPE CHAR5 .

data:var(10).

Select SINGLE f1 into l_table from t1.

Select SINGLE f into var from (l_table)."here ensure that field F is there in table T2.

rgds,

bharat.

Read only

ThomasZloch
Active Contributor
0 Likes
836

what is the exact error message?

is your table name really only 5 characters long (CHAR5)?

Read only

0 Likes
836

Hello,

and thanks for the answer.

I have localized that it has something to do with the concatenate, so I post the original code (the tables have more than 5Char sorry for that).

If I set DATA: l_table Type CHAR20

If I am setting the value for the l_table it works fine so in my opinion it has something to do with the concatenate but the result of the concatenate is also fine i checked it wit se11 the result is exactly the tablename.

The error is:

Laufzeitfehler DBIF_RSQL_INVALID_RSQL

Ausnahme CX_SY_OPEN_SQL_DB

DATA: l_period TYPE char40.

DATA: l_table TYPE CHAR20.

break-point.

Select ODSNAME from rstsods into l_table

where

USEROBJ = '6DB_K5'.

ENDSELECT.

concatenate l_table '000' into l_table." I need this because the value of the table has not the 0

SELECT k850_periode

FROM (l_table)

INTO l_period.

ENDSELECT.

Read only

0 Likes
836

Hi Henning,

the "short" dump should give you more information somewhere about the actual problem: does the table you are accessing dynamically not exist, or does the column k850_periode not exist in that table, or could it be that k850_periode and l_period are defined differently?

Greetings

Thomas

Read only

Former Member
0 Likes
836

Hello,

I found my mistake the table name was not right. What a stupid mistake

But thanks again to all it was very helpfull

Henning