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 statement to pick up field runtime

Former Member
0 Likes
1,141

hi

i hava z-table

Ztable with field puid guid key1 key2 key3.

i want to fetch data for key1 key2 key3 runtime.

data : l_key type ztable-key1,

t_ztable type standard table of ztable with header line.

i wrote query as below

select * into table t_ztable from ztable

where puid eq '1',

guid eq '3',

l_key eq 'ght'.

where l_key will be key1,key2 or key3 as per runtime value.

but it is showing error that l_key is non defined.

I know other solution that putting where clause in one string variable.

But i want to ask whether it is possible to pass runtime field name in sele

hi

i hava z-table

Ztable with field puid guid key1 key2 key3.

i want to fetch data for key1 key2 key3 runtime.

data : l_key type ztable-key1,

t_ztable type standard table of ztable with header line.

i wrote query as below

select * into table t_ztable from ztable

where puid eq '1',

guid eq '3',

l_key eq 'ght'.

where l_key will be key1,key2 or key3 as per runtime value.

but it is showing error that l_key is non defined.

I know other solution that putting where clause in one string variable.

But i want to ask whether it is possible to pass runtime field name in sele

8 REPLIES 8
Read only

Former Member
0 Likes
1,083

Hi harshalata,

first Check your field l_key exist in that table ztable.

then you can proceed to assigining the value at the run time.

runtime only possible with the existance of that field in that table

Thanks

Edited by: Prasanth on Mar 4, 2009 9:16 PM

Read only

Former Member
0 Likes
1,083

You need to use a dynamic condition, it would be something like this

L_key is the name of the field you want to use dynamically


data: l_key(50)

data: begin of itab occurs 0,
cond(72),
end of itab.
itab-cond = 'puid eq ''''1'''' and'. append itab.
itab-cond = 'guid eq ''''3'''' and'. append itab.
concatenate l_key 'eq' '''''3''''.' into itab-cond separated by space.
append itab

select * into table t_ztable from ztable
where (itab).

Read only

Former Member
0 Likes
1,083

Hi,

In Ztable there are only this fields puid guid key1 key2 key3.there is no field with l_key in table ztable.

so it won't work.

Regards,

Sathish

Read only

0 Likes
1,083

hi alll

I want to run query

select * from ztable into table t_ztable

where puid eq 1

guid eq 2

(key1 or key2 or key3) eq 'abc'.

here l_key will hold value either key1,key2,key3 runtime

Read only

0 Likes
1,083

I told you already how to do it. You need to fill the condition in a table.

Read only

0 Likes
1,083

I can achieve that with putting condition in string.

L_where_clause. no need of table too.

Just asking whether we pass Column name of Table runtime without using itab ot l_where_clause (string)

Read only

0 Likes
1,083

You can pass the field name only in where clause by concatenating. we don't any other opions to do that

otherwise you need to look for

http://help.sap.com/saphelp_nw04/helpdata/en/9f/db999535c111d1829f0000e829fbfe/content.htm

Read only

0 Likes
1,083

thanks everyone