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

Insert the Internal table records into the DB table

Former Member
0 Likes
853

Hi all,

I have to insert the Internal table records into the DB table.

the problem is the structure of internal table and DB table is not same

Internal table is having 10 fields and DB table is having 20 fields.

how can i do it?

Thanks

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
810

Let us summarise your requirment like below :

You have table T1 whose rcord you want to update in DB_tab1

but the structure you have maintained is different than the structure of DB_tab1

Here is the soln :

create an internal table T2

Data: T2 type standard table of DB_tab1 initial size 0.

data: wa_t2 type DB_tab1 .

Loop at T1.

wa_t2-field1 = t1-field1.

wa_t2-field2 = t1-field3

wa_t2-field2 = t1-field3

>>>>>>>>>>>>>>>>>>>

wa_t2-fieldn = t1-fieldn.

append t2 from wa_t2.

endloop.

Insert into DB_tab1 from T2.

Hi all,

I have to insert the Internal table records into the DB table.

the problem is the structure of internal table and DB table is not same

Internal table is having 10 fields and DB table is having 20 fields.

how can i do it?

Thanks

6 REPLIES 6
Read only

Former Member
0 Likes
810

Hello,

If the structure is not same then create another internal table similar to the DB and move the corresponding values to it and insert in the DB table.

Vikranth

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
810

Create a internal table of structure Ztbale.

append the data into itab.

then

modify Ztest from table itab.

Read only

former_member404244
Active Contributor
0 Likes
810

Hi,

Declare one internal table as DB table strcure.. Now pass the required fields to this new internal table with the values you have in your other internal table ...Then modify the DB table with the new internal table.

Regards,

Nagaraj

Read only

Former Member
0 Likes
811

Let us summarise your requirment like below :

You have table T1 whose rcord you want to update in DB_tab1

but the structure you have maintained is different than the structure of DB_tab1

Here is the soln :

create an internal table T2

Data: T2 type standard table of DB_tab1 initial size 0.

data: wa_t2 type DB_tab1 .

Loop at T1.

wa_t2-field1 = t1-field1.

wa_t2-field2 = t1-field3

wa_t2-field2 = t1-field3

>>>>>>>>>>>>>>>>>>>

wa_t2-fieldn = t1-fieldn.

append t2 from wa_t2.

endloop.

Insert into DB_tab1 from T2.

Read only

0 Likes
810

...

post duplicate

Read only

Former Member
0 Likes
810

Hi,

You can create your internal table of the type of structure of the

Ztable which needs to be modified.

Then after populating the required fields data into the

internal table you need to use MODIFY statement i.e,

MODIFY ZTABLE FROM TABLE ITAB.

Hope it helps

Regards

Mansi