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 from variable table

Former Member
0 Likes
6,681

hi,

I would like to request your help.

I want to select some data from one table .but the table is dynamic.

It is continuously changing.So what i thought is accept the tablename as

parameter and then do the select from the parameter but the select

statement is not working .

Please advise whether i can select from parameter any data or is there

any other way to do that.

Thanks in advance.

aasr.

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
2,744

Post your code. Are you looking for a dynamic where clause?

Here is a short sample of a dynamic select statement.

Enter your table name in the parameter on selection screen. Enter you where clause in the select-option on selection screen.

I used.....

MARA

MTART = 'HALB'



report zrich_0004 .

data: xwhere(30) type c.
data: iwhere(30) type c occurs 0.

data:itab(1000) type c occurs 0 with header line.

parameters: p_table(30) type c.
select-options: s_where for xwhere.

loop at s_where.
  clear iwhere.
  xwhere = s_where-low.
  append xwhere to iwhere.
endloop.

select * up to 100 rows into table itab
          from (p_table)
                where (iwhere).

loop at itab.

  write:/ itab.
endloop.

Regards,

Rich Heilman

Message was edited by: Rich Heilman

2 REPLIES 2
Read only

RichHeilman
Developer Advocate
Developer Advocate
2,745

Post your code. Are you looking for a dynamic where clause?

Here is a short sample of a dynamic select statement.

Enter your table name in the parameter on selection screen. Enter you where clause in the select-option on selection screen.

I used.....

MARA

MTART = 'HALB'



report zrich_0004 .

data: xwhere(30) type c.
data: iwhere(30) type c occurs 0.

data:itab(1000) type c occurs 0 with header line.

parameters: p_table(30) type c.
select-options: s_where for xwhere.

loop at s_where.
  clear iwhere.
  xwhere = s_where-low.
  append xwhere to iwhere.
endloop.

select * up to 100 rows into table itab
          from (p_table)
                where (iwhere).

loop at itab.

  write:/ itab.
endloop.

Regards,

Rich Heilman

Message was edited by: Rich Heilman

Read only

Former Member
0 Likes
2,744

hi Rich,

Your solution is excellent.

I fixed my problem .

Your knowledge is amazing.

Thanks a ton.

aasr