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

Dynamic DB table name in insert statement

Former Member
0 Likes
1,133

In the following command i was able to build <dyn_table> dynamically but how do we do that for <dyn_wa>. table name should be populated dynamically here.

for ex: pa0001, pa0002, .... and I have these names in an IT table

INSERT <dyn_wa> FROM TABLE <dyn_table>

ACCEPTING DUPLICATE KEYS.

Pls help...Thanks

8 REPLIES 8
Read only

former_member192429
Active Participant
0 Likes
901

Try INSERT (Table_name) FROM ....

Where Table_name has Database table name

-Kriss

Read only

0 Likes
901

what should be the data type of this 'table_name'??

Read only

0 Likes
901

You can use a string type -:)


DATA: table_name type STRING.

Greetings,

Blag.

Read only

0 Likes
901

Hi,

Try with

data : v_table_name like dd08v-tabname.

aRs

Read only

0 Likes
901

data: tab_name type string.

INSERT <dyn_table> into tab_name

ACCEPTING DUPLICATE KEYS.

gives me error " tab_name" is not an internal table.

Read only

0 Likes
901

Take it as charater type.

This code works for me.

TABLES : ztest123.

DATA : tab_name(10) TYPE c.

tab_name = 'ZTEST123'.

DATA : wa LIKE ztest123.

wa-name = 'Mahesh'.

INSERT (tab_name) FROM wa.

Thanks

Mahesh

Read only

0 Likes
901

check ur syntax of the insert statement

it should insert(tab_name) from table Internaltable.

or

insert(tab_name)from workarea.

here tab_name is variable contains the name of the DB table

Thanks,

Mahesh

Read only

0 Likes
901

in my case both the internal table ( wa) and the db table are dynamic