Does anyone know how to declare an internal table dynamically in a program? I need to create a program that will accept from the user (parameter) the name of a Custom Transparent Table. The program would then create an Internal Table having the structure of the Transparent Table specified by the user. I tried using macros but to no avail. The program would look something like this:

parameter: p_tablename type tabname.

data: begin of itab.
include structure p_tablename.
data: end of itab.

Unfortunately this code is not syntactically correct.
Thanks in advance for your time .

Since you are using custom tables, it's possible that there aren't that many. So, you could define your internal tables explicitly for all of these custom tables. That way there would be an internal table available no matter what the user enters.

Note: dynamic table selection has been discussed here many times before. I don't think anyone has yet come up with a way for 100 % dynamic table selection with individual field / structure access for any and all possible tables.

Thank you for all the replies (Vijayendra, projecttoday, kumar, anandksap, Dr Sidewalk). Sorry for my late message, I was only able to view your replies just now. Thanks anandksap for the code. Dr. Sidewalk, I have seen the same topic in the forums before but I didn't realize that the topic appeared that often Thanks again!

Thanks anandksap. Your code worked just fine. However, I still have a problem accessing the fields of my internal table. If I try to display the contents of <f_fs> by command WRITE, the table entries will appear side by side. In your code, itab contains the field names of the table name. I just need to access these field names found in <f_fs>. Is there a way to do this? I added some code to the program you sent, what I want to do is something like that. Thanks in advance!