Showing results for 
Search instead for 
Did you mean: 

variable table name in the select statment ?

Former Member
0 Kudos


data: h_itab like hier_out occurs 0 with header line,

table_name(30) type C.

  • here i declare h_itab as the variable for the table name

itab_name = input_name

  • input_name is imported

select * from table_name

into table h_itab

where OBJVERS = 'A'.


it does not allow me to use table_name in the select statement i get the error 'table_name is not defined i the abap dictionary as a table, projection view or database view'.

Any suggestions are highly appreciated.

Thanks in advance,


Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos


You must enclose the name of the table in braces to let the compiler know that the value will be supplied at run time.

For example -

tables mara.
data table_name(30) type c.

table_name = 'MARA'.

  FROM (table_name)


Anand Mandalika.

Answers (1)

Answers (1)

Former Member
0 Kudos


You want to use the tablename as variable name in the select statement.

If i understand you correctly, modify the select statement as

Select * from (table_name) into table h_itab

where OBJVERS = 'A'.