Skip to Content
0
Former Member
Nov 15, 2005 at 03:34 PM

How to get a variable by its name!

27 Views

Hi Folks,

I have a class with say some 10 internal tables of different types. I want to have a method, which takes the table name as parameter and returns the corresponding table. How could i achieve this?

Let me give a example with the psudo code.

class A

data : table1 type table of i.

data : table2 type table of x.

...

data: table10 type table of c.

the method should be..

getTable(table_name type string) returns result type any table.

{

}

I dont want to use any if or case statement. for example,

-


if table_name = 'table1'

result = table1.

elseif table_name = 'table2'

result = table2

.....

end if.

-


Please suggest some other way where i can get the variable using its literal name.

Thanks in advance!

Regards

Shahul