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: 

program to make the direct entries to the custom tables

Former Member
0 Kudos
342

Hi All,

I have created a program to make the direct entries to the custom tables, I am passing the table as a input. the problem here is when i pass the table dynamically , i am not able to pass the table to the INSERT syntax dynamically.

Regards,

Vijay

9 REPLIES 9

Former Member
0 Kudos
167

Hi,

Can you please share the Insert Statement.

0 Kudos
167

Hi,

Please find the Insert statement below.

INSERT ztest_upload1. "<DB_TAB>. "

  • INSERT INITIAL LINE INTO <DB_TAB> ASSIGNING <fs>.

Vijay

0 Kudos
167

Hi,

I believe INSERT not supports TAble name as Variable ......You need to mention the Table Name in the INSERT Statement.

How Many Tables you are trying to update here?

Former Member
0 Kudos
167

Hi ,

U can pass the table names dynimically to the Insert statement.

Insert (dtab) FROM TABLE itab.

Instead of static specification, a bracketed data object dbtab_syntax can be specified, which must contain the name of the database table or the view when the statement is executed. A character-type data object can be specified for the data object dbtab.

Ensure that the dtab nme passed and the Internal table itab are compatible before passing the data.

Regards,

Radhika.

Former Member
0 Kudos
167

Hi,

You can try with INSERT And MODIFY statment. Check every insert record with sy-subrc. If sy-subrc is not equal to Zero then else statement you use MODIFY.

Regards

Md.MahaboobKhan

Former Member
0 Kudos
167

Hi,

Use MODIFY statement instead of INSERT and check you can insert into the table.

Moreover use COMMIT WORK after MODIFY.

Pooja

Former Member
0 Kudos
167

Hi

Please try this with the below code

DATA:

fs_table TYPE <table-name>,

t_table LIKE

STANDARD TABLE OF fs_table,

t_table1 LIKE t_table WITH HEADER LINE.

fs_table-mandt = 800.

fs_table-name = 'AAA'.

fs_table-empid = '1'.

APPEND fs_table TO t_table.

CLEAR fs_table.

fs_table-mandt = 800.

fs_table-name = 'BBB'.

fs_table-empid = '2'.

APPEND fs_table TO t_table.

CLEAR fs_table.

LOOP AT t_table INTO fs_table.

INSERT <table-name> FROM fs_table.

ENDLOOP.

Regards,

Rajani.

Former Member
0 Kudos
167

hi,

1) Pass the table name to a screen element say p_tab.

2) Write this table name to a target field using

write (p_tab) to w_tab.

where w_tab is another work variable

3) Insert w_tab from table itab.

where itab is your internal table with entries that are to be inserted to the dbtab.

Thanks and regards

Sharath

Former Member
0 Kudos
167

Closed