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 data from itab to database table..

Former Member
0 Likes
1,124

hi guys..

iam inserting one new record from itab to dbtable..

existing record is deleted.. so how can i solve the problem..

my coding

APPEND ITAB .

MOVE-CORRESPONDING ITAB TO ITAB2.

MODIFY ZQUERY1 from ITAB2.

loop is not necessary in my program because i get only one value at that time..

thanks

gowrishankar

10 REPLIES 10
Read only

Former Member
0 Likes
997

Hi,

I feel u need not append as well modify.

both actually performs similar functionality!

try it out.

<<<reward if useful>>>

All the best

Read only

chaithanya_mk
Participant
0 Likes
997

Hi Gowrishankar,

You can use Insert instead of modify in this case. Try the below code

Append Itab.

zquery1-field1 = itab-field1.

zquery1-field2 = itab-field2.

....

Insert zquery.

please reward if found useful.

Read only

Former Member
0 Likes
997

Hi,

You need to use the TABLE other wise it will insert only one record, change it to like .....

APPEND ITAB .
MOVE-CORRESPONDING ITAB TO ITAB2.
MODIFY ZQUERY1 from TABLE ITAB2.

Regards

Sudheer

Read only

Former Member
0 Likes
997

Modify will check if there is a similar record in the DB Table (based on table keys).

If yes, it will update teh data from the itab to teh DB tab, else it will insert the data.

In your case, check whether there is a similar record in the db table based on teh table keys.

Read only

Former Member
0 Likes
997

hi,

TRY CHANGING CODE LIKE THIS..

UPDATE ZQUERY1 from ITAB2.

REGARDS,

NAVNEETH.K

Read only

Former Member
0 Likes
997

Hi gowrishankar

You need to use the INSERT command rather than MODIFY. Modify updates the existing record, insert creates a new one.

eg INSERT zquery1 FROM TABLE itab2.

Kind regards

Andy

Read only

Former Member
0 Likes
997

hi,

While modifying records, it changes values of all the fields except the key fields.

So, make sure that itab2 contains all the fields of ddic tbale Zquery1.


select single * from zquery1 into wa_itab.
if sy-subrc eq 0.
 wa_itab-test = 'ABC'.
endif.

append wa_itab to itab.
modify zquery1 from itab.

This would replace the required fields.

Though it replaces all the fields, the others values wont get disturbed.

Regards

sailaja.

Read only

Former Member
0 Likes
997

use this statement (there is no need of move and modify statements)

<b>Insert zquery.</b>

reward if it helps u

Vijay Pawar

Read only

Former Member
0 Likes
997

insert <dbtab> from table itab [accepting duplicate keys].

but itab should have the same structure like dbtab.

regards

shiba dutta

Read only

alex_m
Active Contributor
0 Likes
997

Change the modify statement.

MODIFY ZQUERY1 from TABLE ITAB2.

Modify statement modify the existing records in DB table if the key field exists otherwise insert the new record.