Application Development 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: 

Dynamically Referring to an Internal Table

sathish_perumal
Active Participant
0 Kudos

Hi,

I have 10 internal table named table1, table2, ...table10. At run time I want refer to these tables dynamically as follows

table<num>-column = 'value'.

<num> will be known only during runtime. It may be any table from table1 to table10 based on different tables. So to minimize coding I want to give the internal table name dynamically.

How to achieve this?

Regards,

Sathish

4 REPLIES 4

Former Member
0 Kudos

u need to write dynamic code which picks up the required table at run time.

Former Member
0 Kudos

i need a clarification

ur using 10 internal table those structure are same or different

if they are same

depends on condition u can use those and tell me the brief description wr ur using those tables so,i can further help u

0 Kudos

The structure of the table will be the same. From a parent internal table based on some conditions internal tables has to be populated, but what ever is the condition may all the tables should be filled in order only ie table1, table2...Some times only one table may get filled some times 9 tables.

I can write code by hardcoding each internal table names but I like to refer to internal tables dynamically. So is it possible to do as follows

num = 1.

loop.

table<num>-column1 = 'Value'.

num = num + 1.

endloop.

-Sathish

0 Kudos

Hi,

One idea I can give is maintain an internal table whose line type is the Table type of your 10 internal tables. Then at run time if you know the NUM then read from this internal table.

READ TABLE it_tab_of_tabs into <field-symb> index num.

This is possible if all your 10 internal tables are of the same type.

Regards,

Sesh