‎2008 May 10 1:28 PM
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??
‎2008 May 10 1:46 PM
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
‎2008 May 10 1:50 PM
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
‎2008 May 10 1:57 PM
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??
‎2008 May 10 2:01 PM
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