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

Update database table

Former Member
0 Likes
710

hello,

i want to modify Database table from internal table. For that i am using the following statement:--

modify <DB table> from table <itab>.

but this is creating an extra record for which ever record we are updating in internal table. the extra record shouldn't be created.

can anyone solve this problem??

4 REPLIES 4
Read only

vinod_vemuru2
Active Contributor
0 Likes
529

Hi Srinath,

MODIFY statement will work like this.

If the entry is there already it will modify thet record. If not there then it will creates that record. If u dont want to create new records and only update existing records then u have to use UPDATE statement

UPDATE dbtab FROM table itab.

Update will modify if that record exist and returns sy-subrc as non zero if entry does not exist.

Check F1 help for more details.

Thanks,

Vinod.

Edited by: Vinod Kumar Vemuru on May 10, 2008 6:18 PM

Read only

Former Member
0 Likes
529

hi check this..

there are two methods..

after this statement use the command

delete dbtab where field = wa_field .

it will delete the extra key record produced..

or use the update command ..

http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/update.htm

regards,

venkat

Read only

Former Member
0 Likes
529

hi..

i tried both update and modify statements. even for update it doesnt work.

now since an extra record is being created, i tried deleting using:--

delete adjacent records from <itab> comparing <field>.

but that is not deleting the extra records . what do i do??

Read only

0 Likes
529

Hi Shrinath,

Dis u sorted ur itab before deleting duplicates. This is Mandatory.

Sort itab BY ....

DELETE ADJACENT DUPLICATES COMPARING....

SORTing should be done by the fields in the COMARRING addition in the same order.

Update statement will work in ur case. May be u r looking at the records created earlier by u. Delete all the records u have created and test now by adding sort statement so that there will be no confusion in testing.

Thanks,

Vinod.

Edited by: Vinod Kumar Vemuru on May 10, 2008 6:31 PM